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 #678
Comments
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
I have been able to submit the Typeform form just now. I didn't even try to include any SQL in the question about examples of views, due to the warning they gave in the question text. |
Yeah, I ended up just linking to a gist instead. At least TypeForm was nice enough to remember my responses between refreshes. |
@floelhoeffel seeing you are making some progress on this feature! :D neat! Give me a shout if you want to jump on a 15-30 min call to bounce some ideas. My use-case is serverless, but more importantly my users are navigating my DB through SQL, but might not have full knowledge of the db nor the ins and outs of SQL. Views and materialized views would be a great way to allow users to easier use the DB for their work. The project is fairly greenfield, so might be a good one for a dummy test of any beta features you might have ! :) |
I know this feature is in development (and that's awesome!), but is there any ETA for the (BETA) release? |
@413n Soon. Very soon. |
woohoo!!! |
Yess !! I just started a new project and checked this thread to discover this pleasant surprise. Just being able to avoid the hassle with the db migrate is a great step forward. |
Looks like there are some docs! https://www.prisma.io/docs/concepts/components/prisma-schema/views |
Oh, seems we forgot to post about that here! Ahem... Yes indeed, 4.9.0 brought initial support for Views in Prisma ORM. Based on the survey we prioritized introducing the Read more in our documentation: https://www.prisma.io/docs/concepts/components/prisma-schema/views |
And while I am here: We are adding Introspection support for views for PostgreSQL with 4.10.0 next Tuesday.
Thanks. |
Does it work with materialized views? |
@lcswillems Seems to work great for me with materialized views so far in Postgres!
…On Tue, Feb 7, 2023 at 12:11 PM Lucas Willems ***@***.***> wrote:
Does it work with materialized views?
—
Reply to this email directly, view it on GitHub
<#678 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB53IRM5HWFK5KCP2HQAK73WWKT63ANCNFSM4I6E26EA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Yes, you only need to call the refresh function to refresh the materialized views manually for now via raw queries. We might make that more convenient later. |
We added support for Introspection of views in PostgreSQL today: https://github.com/prisma/prisma/releases/tag/4.10.0 |
This comment was marked as outdated.
This comment was marked as outdated.
In Prisma 4.12.0 we added support for creating files based on the introspected views with their SQL query they run, and we are looking for feedback if this works as expected. More information here: #17335 (comment) |
Problem
In a database, a view is the result set of a stored query on the data, which the database users can query just as they would in a persistent database collection object. Unlike ordinary base tables in a relational database, a view does not form part of the physical schema: as a result set, it is a virtual table computed or collated dynamically from data in the database when access to that view is requested. Changes applied to the data in a relevant underlying table are reflected in the data shown in subsequent invocations of the view.
Prisma does not currently support database views.
Suggested solution
No suggestion.
Alternatives
The current workaround available is to manage views manually and query views by using the raw SQL API.
Or use the documented workarounds https://www.prisma.io/docs/guides/database/advanced-database-tasks/sql-views-postgres or https://www.prisma.io/docs/guides/database/advanced-database-tasks/sql-views-mysql but make sure to read the "Limitations" section properly!Alternatively you can treat a "fake model" to your Prisma schema that has the same structure than the view results. Note that future Introspection might drop this "model" and future Migrations might try to create a table of that name - so make sure to handle that.
Additional context
Frameworks like Ruby on Rails don't support views out of the box, but there are 3rd party libraries available (scenic for Rails).
Original issue
The text was updated successfully, but these errors were encountered: