Skip to content

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

Merged
merged 4 commits into from
Jun 23, 2025

Conversation

etiennejouan
Copy link
Contributor

@etiennejouan etiennejouan commented Jun 23, 2025

Test :

  • For company for example, in import, update of domainName works (Export companies, import them updating domainName.primaryLink)

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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 in graphql-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

Comment on lines 215 to 218
//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) };
}
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor

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 ?

Copy link
Contributor

@prastoin prastoin Jun 23, 2025

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

@etiennejouan etiennejouan changed the title fix import with multiple unique constraint Import - fix import with multiple unique constraints Jun 23, 2025
Copy link
Contributor

github-actions bot commented Jun 23, 2025

🚀 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.

Copy link
Contributor

@prastoin prastoin left a 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

Comment on lines 215 to 218
//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) };
}
Copy link
Contributor

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

Comment on lines 215 to 218
//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) };
}
Copy link
Contributor

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 ?

@etiennejouan
Copy link
Contributor Author

As discussed with @prastoin, the best solution is to check for existing records, parallelising conditions on conflicting fields

Copy link
Contributor

@prastoin prastoin left a 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

@etiennejouan etiennejouan enabled auto-merge (squash) June 23, 2025 14:24
@etiennejouan etiennejouan merged commit facd2fe into main Jun 23, 2025
54 of 58 checks passed
@etiennejouan etiennejouan deleted the ej/fix-export-import branch June 23, 2025 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants