-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Import - fix import with multiple unique constraints #12784
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
Conversation
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.
PR Summary
Updates import functionality to handle multiple unique constraints, focusing on the buildWhereConditions
method in the GraphQL query resolver.
- Modified
buildWhereConditions
ingraphql-query-create-many-resolver.service.ts
to prioritize 'id' field when searching for existing records - Added documentation regarding unique constraint handling, noting that uniqueness can be based on field combinations
- TODOs added to improve handling of conflicting fields based on unique indices rather than field metadata
1 file reviewed, 2 comments
Edit PR Review Bot Settings | Greptile
//TODO : Use one constraint only - id by default - https://github.com/twentyhq/core-team-issues/issues/1115 | ||
if (field.column === 'id') { | ||
return { id: In(fieldValues) }; | ||
} |
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.
logic: Early return with id-based condition bypasses other unique constraints. Consider the impact on records with multiple unique fields.
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.
Mmmmhmm that's not false
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.
Shouldn't this be a continue ?
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.
Discussed this with @etiennejouan, we might wanna give a try to an OR
condition instead of the early returning on id
so we could be sending two unique fields that are not the id one
...ine/api/graphql/graphql-query-runner/resolvers/graphql-query-create-many-resolver.service.ts
Outdated
Show resolved
Hide resolved
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:37242 This environment will automatically shut down when the PR is closed or after 5 hours. |
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.
Left a question Senore Jouan
//TODO : Use one constraint only - id by default - https://github.com/twentyhq/core-team-issues/issues/1115 | ||
if (field.column === 'id') { | ||
return { id: In(fieldValues) }; | ||
} |
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.
Mmmmhmm that's not false
//TODO : Use one constraint only - id by default - https://github.com/twentyhq/core-team-issues/issues/1115 | ||
if (field.column === 'id') { | ||
return { id: In(fieldValues) }; | ||
} |
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.
Shouldn't this be a continue ?
As discussed with @prastoin, the best solution is to check for existing records, parallelising conditions on conflicting fields |
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.
Left two nitpicks ! still approving
Test :