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

Add support for database views #555

Merged

Conversation

matthewmcgarvey
Copy link
Member

Fixes #453

To declare a view, instead of using the table macro, there is now a view macro. There are a few differences between the two:

  • There are no default columns. If your view has a primary key or timestamps, they must be defined explicitly
  • No Model::SaveOperation is defined
  • If the view does not have a primary key, some methods don't work or will be missing
    • Avram::Model#reload raises a compilation error if invoked without a primary key
    • Model::BaseQuery no longer includes Avram::PrimaryKeyQueryable which has methods like #find that require a primary key

No functionality around materialized views is included with this change.

@matthewmcgarvey
Copy link
Member Author

🚫 SchemaEnforcer fails. All columns for views are nilable. We'll have to be able to configure that check

@matthewmcgarvey matthewmcgarvey marked this pull request as draft December 4, 2020 22:15
@matthewmcgarvey
Copy link
Member Author

This requires #556 to be merged first

@matthewmcgarvey matthewmcgarvey marked this pull request as ready for review December 8, 2020 20:37
Copy link
Member

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the main thing will be to see how this works inside Lucky itself. But lets get it out there and give it a spin!

@matthewmcgarvey matthewmcgarvey merged commit 32d5d59 into luckyframework:master Dec 8, 2020
@matthewmcgarvey matthewmcgarvey deleted the database-views branch December 8, 2020 21:13
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

Successfully merging this pull request may close these issues.

Add support for database views
2 participants