-
Notifications
You must be signed in to change notification settings - Fork 26
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
[MechDB] ActiveRecord is not created for view without _id column #145
Comments
It was actually a conscious decision to not generate active record classes for tables or views that do not have an _id column. Do you have a case where you need one? |
If you want to use an active record as a convenient way to access your data from a cursor. I have the issue especially for views where no meaningful _id column exists. Consider the following tables modelling a * to * relationship: artists albums artist_album_relation If you now want to create a view, containing the albums with their corresponding artists you would do something like
In this case you can of cause chose one of the two Ids as a _id field but it wouldn't really make sense. |
Ok, I see your point, as a workaround you could give a dummy id such as:
If we were to generate ActiveRecord for all then it would mean we would need to change the base ActiveRecord class to remove the id property, as well as some methods that require id such as the static get, etc. |
That's exactly the workaround that I apply. If the behavior is intended and won't be changed, I suggest that some kind of a hint should be added to the documentation. Took me a while to figure out that the missing _id column was the problem. |
Cool cheers I will update the docs to make sure this is clear |
If a view is defined in the database that has no column called "_id" no ActiveRecord class is created for this view.
Example:
The text was updated successfully, but these errors were encountered: