-
Notifications
You must be signed in to change notification settings - Fork 73
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
Please allow to specify two or more primary key columns (composite primary key) #114
Comments
That's correct that reform assumes single-column primary key for But I'm not sure why you think it has to be of a serial type. That's true that As for the first part of the issue. While it's not possible to generate a I guess what you really want is some form of many-to-many relationship support. That may come after we investigate and implement support for one-to-many (#54). (edited: formatting) |
I don't want many to many support in the ORM. I would like to have composite keys (possibly with some manual extension not to slow down the common path) and I would like someway to generate INSERT directly from Save when I know the key, instead of an UPDATE checking for 0 rows (this is a very wasteful round trip). Possibly this might require some flag to be set manually by the user to indicate that this row is a new row (and INSERT should be called instead of UPDATE). Using Insert worked for me but IMHO having two interfaces that essentially do the same thing is confusing. I think overall the library is nicely made and could be useful. |
I have a table with two foreign keys (id1 and id2), there are no other columns in the table.
The primary key on this table is a composite key (id1,id2).
The current version of go-reform does not allow to specify such a primary key.
This is a common case and there is no way to use save on such a schema.
In general go-reform always assumes that there is only one primary key column and it's a serial type.
It's not even possible to preset it to some value and save the record (the library generates an UPDATE in this case)
This is a strange requirement for a generic library.
The text was updated successfully, but these errors were encountered: