-
Notifications
You must be signed in to change notification settings - Fork 409
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
Support INSERT statement over SQL adapter #7462
Conversation
This PR is getting big, so I think it is better to merge what's done and iterate later. But it being big is not the only reason: I'm not confident with the general approach so I think it is ready to be reviewed. There is still a few minor questions open, see TODO comments. But stuff now generally works, including the hard thing that is multiple DML stmts, passing values between them. The other hard thing (link tables) is left to do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
Could you make a list of all the TODOs and put it in the issue?
if is_link: | ||
val_col_pg = pgast.TypeCast( | ||
arg=val_col_pg, type_name=pgast.TypeName(name=('uuid',)) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To produce a better error when users are trying to insert non-uuids into link columns.
For example:
edgedb=# INSERT INTO "Document" (owner_id) VALUES (4);
ERROR: cannot cast type integer to uuid
LINE 1: INSERT INTO "Document" (owner_id) VALUES (4);
^
Not great, but better than talking about "operator =
not existing for uuid and integer".
|
||
if not res_query.ctes: | ||
res_query.ctes = [] | ||
res_query.ctes.extend(pg_res_rel.extract_ctes_from_ctx(ctx)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these ctes wind up nested then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. extract_ctes_from_ctx
returns a list of ctes, but only when ctx is top-level.
This is here to achieve exactly the opposite: have all generated CTEs at the top-level.
Todo and general implementation strategy tracked in #7294