Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL - batch update failed #216

Closed
suchym opened this issue Feb 2, 2023 · 9 comments
Closed

PostgreSQL - batch update failed #216

suchym opened this issue Feb 2, 2023 · 9 comments

Comments

@suchym
Copy link

suchym commented Feb 2, 2023

Vita generated this script that failed with the message:
42601: syntax error at or near "DELETE"
POSITION: 56

The generated script:
UPDATE pathway."Pathway"
SET "OrderId" = CAST(0 AS smallint), "ModifyDate" = '2023-02-02T14:29:25.20403', "Timestamp" = '2023-02-02T15:19:51.23444'
WHERE "Id" = 1;
DELETE FROM pathway."Edge"
WHERE "Id" = ANY(@p0)
DELETE FROM pathway."Place"
WHERE "Id" = 3;
DELETE FROM pathway."Transition"
WHERE "Id" = 2;

I think that the problem is in the line: WHERE "Id" = ANY(@p0) - the semicolon is missing.
Parameter @p0 is an integer array parameter containing two integers.
The script is logically correct. Thank you, VITA.
Is there any easy workaround?
Thank you in advance

@rivantsov
Copy link
Owner

I will look at it, but I need some more context. How the update operation was constructed? This DELETE with Any, it looks like it is made from Linq and then scheduled for execution on SaveChanges? Pls provide some pseudo code or general sequence what was going on

@suchym
Copy link
Author

suchym commented Feb 3, 2023

VITA_UPDATE Script.pptx
The presentation will show you very briefly what Pathway, Place, Transition, and Edge represent.
In the second slide, you can see that one place and one transition, along with two edges (not visible), are removed.

The Pseudo code looks like this:
Find what changed (removed place, transition, and two edges)
This code is executed for each entity

public void Delete(IList<int> identifiers)
        {
            if (identifiers == null || !identifiers.Any())
                return;

            foreach (var pk in identifiers.Select(identifier => Session.CreatePrimaryKey<TEntity>(identifier)))
            {
                Delete(pk);
            }
        }
public TEntity Delete(object id)
        {
            Entity = this.GetEntity(id);
            if (Entity == null) return null;
            Session.DeleteEntity(Entity);
            return Entity;
        }

....
....
and then this line is called at the end
Session.SaveChanges();

Place, transition contains one identifier and edges two, the script is generated correctly from my point of view but only the semicolon is missing.
Pathway is updated due to modify date.

@suchym
Copy link
Author

suchym commented Feb 3, 2023

I ran the 'TestMics_DeleteMany' test and the command text is without ;
You can see the delete script:

DELETE FROM misc."Driver" 
    WHERE "Id" = ANY(@P0)

In this case, missing semicolon doesn't matter.

@rivantsov
Copy link
Owner

wow, fancy chemistry! ok, got it, will look at it over weekend and push the fix

@rivantsov
Copy link
Owner

pushed fix, v 3.5.1, should be working now

@suchym
Copy link
Author

suchym commented Feb 6, 2023

The problem persists even after updating VITA to 3.5.1. version:

UPDATE pathway."Pathway"
    SET "ModifyDate" = '2023-02-06T19:09:20.07359', "Timestamp" = '2023-02-06T20:09:15.20968'
    WHERE "Id" = 1;
DELETE FROM pathway."Edge" 
    WHERE "Id" = ANY(@P0)
DELETE FROM pathway."Place" 
    WHERE "Id" = 3;
DELETE FROM pathway."Transition" 
    WHERE "Id" = 2;

@rivantsov
Copy link
Owner

sorry, looking at it...

@rivantsov
Copy link
Owner

fixed, pushed 3.5.2, try it

@suchym
Copy link
Author

suchym commented Feb 7, 2023

It works. Thank you very much for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants