Primary key is not "id"
See original GitHub issueI tried to declare the user table as:
table.increments('user_id').primary();
table.string('username');
but when I do a HTTP GET call to the server /user/1
I got the error
{
"name": "BadRequest",
"message": "select `user`.* from `user` where `id` = '1' - ER_BAD_FIELD_ERROR: Unknown column 'id' in 'where clause'",
"code": 400,
"className": "bad-request",
"errors": {}
}
Expected result
the user record would be shown accordingly.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Is it ever a good idea to not have an 'id' primary key for a table?
Longer answer: if you have a table to be used in a many-to-many relationship, you don't really need a primary key. Then it...
Read more >When your table's primary key is not called ID? - Laracasts
I'm trying to get laravel to play nicely with a legacy DB structure. Here is it: products products_id, products_name, products_price products_to_categories ...
Read more >Add or change a table's primary key in Access
Often, a unique identification number, such as an ID number or a serial number or code, serves as a primary key in a...
Read more >404 after create when primary key is not id · Issue #189 - GitHub
When creating a new resource, it tries to go to the view resource page by grabbing . id off the returned object. However,...
Read more >ID Column if not Primary Key? - SQL Server Forum
Solution: If you have no other unique identifier in your table, then using an identity column as the primary/clustered key is fine.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you want to use an id key that is not
id
you have to tell the adapter whichid
property to use when initializing the service as documented here.Can you share a repository to reproduce the issue?