Closed Ceda closed 1 year ago
This looks good except for one small problem and that is that some Identity columns can be generated.
There are two cases for generated identity columns
GENERATED BY DEFAULT
and GENERATED ALWAYS
The latter of which causes problems by making insert statements fail.
In the case that an IDENTITY
column is GENERATED BY DEFAULT
the column should simply be inserted as normal.
In the case that an IDENTITY
column is GENERATED ALWAYS
the insert statement should have OVERRIDING SYSTEM VALUE
following the column list e.g.
INSERT INTO user
(id, name, password)
OVERRIDING SYSTEM VALUE
VALUES
(1, 'user', 'password123');
An identity columns' generated status can be discerned via the pg_attribute.attidentity
field.
This field can be one of three values:
GENERATED ALWAYS
GENERATED BY DEFAULT
I'll do my best to include these changes in my free-time but feel free to take care of it yourself as well. Thank you!
P.S. here's some relevant links to this problem Stack Overflow, PG Docs
I have made a PR off of your PR that will add the requested changes that I commented. Once you merge that PR, I can merge this one as well. Thanks!
I have made a PR off of your PR that will add the requested changes that I commented. Once you merge that PR, I can merge this one as well. Thanks!
Nice work, thank you... I squashed your code into my branch...
Thank you @Ceda !
I have same issue like #40 this PR detect generated columns from schema and prevent inserting. Is working for Postgres, same issue for MySQL here #28