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

fixing these tags were not generated on the ORM struct: #185

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alkaaf
Copy link

@alkaaf alkaaf commented Apr 8, 2020

these tags were not generated (recognized as empty and it hurts my head). i have strong thought that was a bug. i fixed it and tested it.

foreignkey
association_foreignkey
many2many
jointable_foreignkey
association_jointable_foreignkey
association_autoupdate
association_autocreate
association_save_reference
preload

foreignkey
association_foreignkey
many2many
jointable_foreignkey
association_jointable_foreignkey
association_autoupdate
association_autocreate
association_save_reference
preload
@Calebjh
Copy link
Contributor

Calebjh commented Apr 8, 2020

Hmm. When I test it by adding one of these tags to an arbitrary field

google.protobuf.Timestamp created_at = 7 [(gorm.field).tag.association_jointable_foreignkey = "foobar"];

I'm seeing the output tag generated as expected

CreatedAt *time.Time `gorm:"association_jointable_foreignkey:foobar"`

Can you give more details?

@alkaaf
Copy link
Author

alkaaf commented Apr 9, 2020

i see, maybe that works well on non-repeated field. this is what i tried:

int32 max_retry = 11 [(gorm.field).tag = {foreignkey:"non_repeated"}];
    repeated SledinData sledin_data = 12 [(gorm.field).tag = {foreignkey:"repeated_field" association_foreignkey:"foobar"}];

and here is what i got

MaxRetry     int32 `gorm:"foreignkey:non_repeated"`
SledinData   []*SledinDataORM `gorm:"foreignkey:SledinBlastIdblast;association_foreignkey:Idblast"`

@alkaaf
Copy link
Author

alkaaf commented Apr 9, 2020

after i change the plugins.go, i got the right result for both repeated and non repeated. i don't know about the side effect yet.

int32 max_retry = 11 [(gorm.field).tag = {foreignkey:"non_repeated"}];
repeated SledinData sledin_data = 12 [(gorm.field).tag = {foreignkey:"repeated_field" association_foreignkey:"foobar"}];

the result:

MaxRetry     int32 `gorm:"foreignkey:non_repeated"`
SledinData   []*SledinDataORM `gorm:"foreignkey:repeated_field;association_foreignkey:foobar"`

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.

2 participants