Skip to content
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

gormschema: support customize JoinTable #40

Merged
merged 9 commits into from
Apr 25, 2024
Merged

Conversation

luantranminh
Copy link
Collaborator

Fix #39

@luantranminh
Copy link
Collaborator Author

@ronenlu 👀 Could you have a look? Happy to discuss more

@ronenlu
Copy link
Member

ronenlu commented Apr 20, 2024

@ronenlu 👀 Could you have a look? Happy to discuss more

@luantranminh Thank you for your contribution! I will review the PR soon

gormschema/gorm.go Outdated Show resolved Hide resolved
gormschema/gorm.go Outdated Show resolved Hide resolved
gormschema/gorm.go Outdated Show resolved Hide resolved
gormschema/gorm.go Outdated Show resolved Hide resolved
@luantranminh
Copy link
Collaborator Author

Looking at the unit test at the moment, the CREATE CONSTRAINT is not in the desired order, and it's also different when I run the test on my machine. 🏃‍♂️

@luantranminh
Copy link
Collaborator Author

luantranminh commented Apr 21, 2024

I found interesting stuff here. GORM stores table relationships inside a Map. Looping through a Map is not guaranteed to produce the same order all the time.

https://github.com/go-gorm/gorm/blob/8c18714462de07fa3392b99eda089f2f9e3b6042/schema/schema.go#L186
image

We're looping through it here:

for _, rel := range stmt.Schema.Relationships.Relations {

Resulting SQL statements output could be different each time the CI runs
It hurts our tests, but the migration files are fine. I'll submit another commit to sort the Relations out before looping.

@giautm giautm changed the title Support Customize JoinTable gormschema: support customize JoinTable Apr 22, 2024
@luantranminh
Copy link
Collaborator Author

Ronen said the forked project is missing Secrets to run the integration tests
image

@giautm
Copy link
Member

giautm commented Apr 22, 2024

Ronen said the forked project is missing Secrets to run the integration tests image

Yes, because the repo's secret doesn't share with the forked repository.

@giautm giautm requested a review from ronenlu April 22, 2024 04:13
gormschema/gorm.go Outdated Show resolved Hide resolved
@ronenlu ronenlu merged commit ed0d712 into ariga:master Apr 25, 2024
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Defect] Handle Customize JoinTable
3 participants