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

Document How Postgres can't infer a view's primary key #77

Closed
seanpdoyle opened this issue Nov 4, 2015 · 4 comments
Closed

Document How Postgres can't infer a view's primary key #77

seanpdoyle opened this issue Nov 4, 2015 · 4 comments
Milestone

Comments

@seanpdoyle
Copy link

@calebthompson: @derek We’re using Scenic. While inspecting with pg, the view has an `id` column, but `TheViewModel.first.id == nil` and `TheViewModel.find(1)` complains about not having a primary key

calebthompson [14:58] 
`self.primary_key = :id`

sean [14:58] 
Setting `self.primary_key = "id"` resolved the issue. Am I doing something wrong

calebthompson [14:58] 
Nope.

calebthompson [14:58]
Views can’t have primary keys in postgres.

calebthompson [14:58]
We could probably benefit from having that in the README.
@seanpdoyle seanpdoyle changed the title Document How Postgres can't infer a view Document How Postgres can't infer a view's primary key Nov 4, 2015
@derekprior
Copy link
Contributor

I dont think there's anything we can do about this at runtime unless we introduce a Scenic::Model module or base class which could inspect at runtime and make the proper primary_key call for you.

I'm leaning towards a documentation change to cover this as well. @calebthompson Would you also rule out a runtime fix?

@calebhearth
Copy link
Contributor

I think this is to add a note to the README.

@calebhearth
Copy link
Contributor

That was the result of the conversation that led to this issue.

@derekprior
Copy link
Contributor

I'd like it to live in actual documentation as well - just not sure where. I'll poke around.

derekprior added a commit that referenced this issue Nov 6, 2015
derekprior added a commit that referenced this issue Nov 6, 2015
@derekprior derekprior modified the milestone: v1.0.0 Nov 6, 2015
derekprior added a commit that referenced this issue Nov 11, 2015
derekprior added a commit that referenced this issue Nov 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants