-
Notifications
You must be signed in to change notification settings - Fork 34
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
Using a different name than "id" for the primary key #148
Comments
Okay, so this actually going to be a real issue I would like to open, as I did not find something about it in the docs or other issues: Is it possible to read from a database whose tables do not have a column "id" as the primary key but something else? I am mainly concerned about accessing existing sqlite databases, and this might be an issue for me. (Also, as a side note: I might start to work on a transpiler which parses sqlite schemas and produces norm types as output, for the same reason) |
I've looked into this issue and found the blocker that I need to resolve in order to proceed with the actual solution. Currently, the SQL that is generated for Postgres doesn't allow any customization in primary key name or type. It's hardcoded as I've been really busy with other stuff lately but I'm determined to find the time to move Norm forward. |
Great, thanks for the response :-) |
I was just considering using norm to clean up my code that has way too much raw SQL, but this seems like a big issue. I'd like to create sqlite tables that have a custom name for the primary key, with value that I provide, not generated automatically. |
I did approach this problem but it turned out to be a lot harder than I had thought initially. It's very convenient to have "id" as a reserved special column name for query generation, so there are many places in the code where this is used. |
I see. Thanks for looking at it anyway! |
I was similarly hoping there was a way to use something other than "id". We prefix all our id columns with the table name, such as "customerId" where "customer" is the name of the table. Would that be possible to handle as an enhancement? |
@gwque unfortunately id is a reserved name and many places in the code depend on it. You can have your customers and stuff along with id if that's a viable option. |
No description provided.
The text was updated successfully, but these errors were encountered: