-
Notifications
You must be signed in to change notification settings - Fork 35
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
Resolve target Model primary key type for BelongsTo|HasManyKey|HasOnKey #118
Conversation
Instead of hard-coding the Type of a BelongsTo|HasManyKey|HasOneKey relationship to be in, resolve the target model in the relationship and use its PrimaryKey as xID type in source struct. Note: Currently this will panic if multiple PrimaryKeys are defined. fixes goadesign#115
Just noticed, while the correct Go Type is now working, the SQLTag type is not. And SQLTag can contain anything, so I guess we need to parse it and look for 'only parts of it' that would be relevant to a foreign key. (e.g. type is, but default is not) Maybe we need to open up this in the DSL? BelongsTo("Identity", func() {
SQLTag("type:uuid")
}) |
Also, BelongsTo filters currently not working. Hardcoded to int |
return "int" | ||
} | ||
modelName := strings.Replace(f.FieldName, "ID", "", -1) | ||
model := f.Parent.BelongsTo[modelName] |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
some questions in the code, generally I don't see a problem. Have you generated an app with this yet? |
Yes I have. This was what I had to do to get UUID working. :) It's currently semi depending on a change in Goa as well to reintroduce satori/go.uuid that has the Scan/Value interface implemented. |
The current impl shortcuts a little and makes it "BelongsTo("Model", "SQLTag")' as oppose to passing in a dsl func to BelongsTo that supports SQLTag. What's your opinion here? |
d5155c8
to
11ef22c
Compare
I'm currently blocked on Gorma UUID support. Any idea when this PR might be merged? |
Instead of hard-coding the Type of a BelongsTo|HasManyKey|HasOneKey relationship
to be in, resolve the target model in the relationship and use its PrimaryKey as
xID type in source struct.
Note: Currently this will panic if multiple PrimaryKeys are defined.
fixes #115