[#190]: Add upsert support via onConflict argument - #622
Closed
matt-metivier wants to merge 6 commits into
Closed
matt-metivier wants to merge 6 commits into
matt-metivier wants to merge 6 commits into
Conversation
Author
- Rename updateColumns to updateFields
- Rename {Table}UpdateColumn enum to {Table}Field
- Rename {Table}Constraint enum to {Table}OnConflictConstraint
- Keep DO NOTHING improvement for empty updateFields
- Make graphql_column_field_name method public - Add OnConflictInput to all __Type match arms (kind, name, description, fields, interfaces, enum_values, input_fields) - Add TableColumns and OnConflictTarget to EnumSource match in parser_util.rs - Fix string comparison in builder.rs using as_str()
Move where_clause computation inside the else branch in on_conflict_clause so param_context is not mutated when update_fields is empty (do nothing path). Also apply rustfmt to builder.rs lines that exceeded the line length limit.
This reverts commit 9aa4a28.
78 commits of master, one real conflict in src/graphql.rs: master added introspection_enabled and is_schema_introspection_enabled next to graphql_column_field_name, while this branch had widened that method to pub. Kept both, since builder.rs resolves onConflict updateColumns names through it. cargo fmt reflowed three spots in builder.rs and transpile.rs where master's changes met ours. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Author
|
Closing. This has been open since January with no reviewer, and it no longer builds against master. If someone wants to review it I'll rebase and reopen. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an
onConflictargument to insert mutations soINSERT ... ON CONFLICT DO UPDATEis reachable through the API. Closes #190.Each table with a usable unique index gains a
{Table}OnConflictinput takingconstraint,updateColumnsandfilter, backed by a{Table}Constraintenum of index names and a{Table}UpdateColumnenum of updatable columns. Index names come frompg_class. The argument is only exposed on tables that have a valid constraint, so serial and generated primary keys do not get it, since constraint columns have to be insertable. An emptyupdateColumnstranspiles toDO NOTHING.Tests in
test/sql/mutation_insert_on_conflict.sql.Based on #503, reimplemented on current master without the unrelated changes.