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

orm does not accurately describe how foreign keys work #23339

Closed
islonely opened this issue Jan 2, 2025 · 2 comments
Closed

orm does not accurately describe how foreign keys work #23339

islonely opened this issue Jan 2, 2025 · 2 comments
Labels
Unit: Documentation Bugs/feature requests, that are related to the documentations.

Comments

@islonely
Copy link
Contributor

islonely commented Jan 2, 2025

Describe the issue

This foreign keys is wrong in all the orm tests and in the docs. This is what the docs and orm tests use. The vlib/orm/orm_fk_test.v test does not detect the issue because it doesn't check the fields with fkey to make sure they're correct. Took me forever to figure out why I couldn't get arrays to work with my orm structs.

struct Foo {
    id          int         @[primary; sql: serial]
    children    []Child     @[fkey: 'parent_id']
}

struct Child {
    id        int    @[primary; sql: serial]
    parent_id int
}

This is what it should be

struct Foo {
    id          int         @[primary; sql: serial]
    children    []Child     @[fkey: 'id']
                                   // ^ This should be the column with the sql PRIMARY constraint on the Child table
}

struct Child {
    id int    @[primary; sql: serial]
}

Links

https://modules.vlang.io/orm.html
Scroll to the usage section.

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Huly®: V_0.6-21770

@islonely islonely added the Unit: Documentation Bugs/feature requests, that are related to the documentations. label Jan 2, 2025
@islonely
Copy link
Contributor Author

islonely commented Jan 2, 2025

I might actually be wrong on this... nobody change anything yet

@islonely
Copy link
Contributor Author

islonely commented Jan 2, 2025

I was wrong about this. I was confused because id int @[serial] and id int @[sql: serial] do not do the same thing and the ORM docs say they do.

@islonely islonely closed this as completed Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Unit: Documentation Bugs/feature requests, that are related to the documentations.
Projects
None yet
Development

No branches or pull requests

1 participant