-
Notifications
You must be signed in to change notification settings - Fork 88
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
Set the primary key to a new record #143
Comments
If the database column for the primary key is (BIG)SERIAL, I don't think you should manually insert your own ID into the field. You will get out of wack pretty quickly doing that. Can you explain your use case? Is your primary key using (BIG)SERIAL? If not, are you planning of generating your own unique id's? We talked about allowing someone to disable the primary and allowing you to handle it yourself. Would that solve your problem? |
Yep. There are two use cases.
Here, I'm now facing the former problem. And I've already supported natural keys in my fork. It works with My main concern is just using natural keys. And this issue is one method to solve it. So any other solutions are welcome! 😄 |
@maiha Your solution is what was recommended by @faustinoaq . I think its a good start. Go ahead and submit a PR. We will get your changes merged. Thanks. |
Any update on this? Having support for natural keys is pretty important in my use cases. |
^ @Blacksmoke16 see more: https://github.com/amberframework/granite-orm/pull/153 |
@Blacksmoke16 granite_orm:
github: maiha/granite-orm
branch: master |
@maiha is this still a WIP? |
No. I've completed in my fork. |
We can set the primary key for a new record on Rails(5), but can't on Granite.
Although we can set
id
by using setter rather than mass assignment, UPDATE is executed even if it is a new record. In this case,save
succeeds but no new records will be created.I like the behavior of Rails as follows. Also, I would like to modify the code like that.
Thought?
The text was updated successfully, but these errors were encountered: