[RFC] Proposal: Support views, materialized views and foreign tables #17265
Replies: 13 comments 22 replies
-
Dig this! The only thing I'm not on board with here is the reliance on raw SQL to create the views. Even though it gives the most flexibility, it also opens up a pretty nasty attack vector1, and means that it's very easy to add parts to a view that may or may not be supported by Directus (yet). It also means that the exact way to configure a view is different between various vendors, which makes documentation very tricky. It also means that we expect the user to be intimately familiar with SQL, which goes against the no-code/low-code approach of the app. I'm wondering how we can rely on a more user friendly UX that configures this through the API methods rather than SQL. (With the knowledge that Directus will still rely on mirroring of the DB, so advanced usage can be achieved by running the SQL directly in-DB) Footnotes
|
Beta Was this translation helpful? Give feedback.
-
@rijkvanzanten I don't see any problem with creating a virtual collections based on raw SQL(or via JS for that matter). At least for self-hosted. You already allow extensions to be loaded and you also allow to run JS through the UI via the "Run script" operation which even if using vm/vm2 it is not bulletproof. Both (extensions and "Run Script") are considered advanced features and both can be restricted in some way. This would be just another feature that needs good handling. Also, it is something other "internal tools" competitors offer out-of-the-box. |
Beta Was this translation helpful? Give feedback.
-
Is there a blocker to manually creating a view in postgres and marking it all read-only in directus, and just using it for read-only? (What is "mirroring" a collection I've seen referenced in various places?) EDIT: I tried it - I made a collection inside directus then replaced it with the view inside postgres. But it shows up only as a folder or something inside directus. I assume the data-introspection realized it's not a real table and deleted the fields... |
Beta Was this translation helpful? Give feedback.
-
While I had great hopes for the View support, ultimately we dropped the fork we'd made that had this View support. We needed production stability and without the hassle of merging updates. Our workaround, is that we have triggers that drop and regenerate postgres "unlogged" tables. And oddly enough, this has actually worked really well. It is more or less the same as how a materialized view works, and has all the performance benefits versus tradition views (as the underlying query to build these is quite complex and resource intensive). And for the most part, the bookmarks and saved queries in Directus are good enough that we've just phased out the extensive use of views we previously had. It's one of many examples of how we've re-architected our database design to function better with Directus, because Directus is such a good fit for our internal apps and db management. It was worth it. I'd recommend anyone stuck by the lack of view support to consider "unlogged tables" with a trigger or cronjob to regenerate them. |
Beta Was this translation helpful? Give feedback.
-
Heya! Thanks for opening this feature request! This feature request has received over 15 votes from the community. This means we'll move this feature request to the Under Review state! The Core team will schedule a meeting to review this request as soon as possible. The discussion will then be approved or denied. You may or may not be invited to join this meeting with the core team. For more information, see our Feature Request Process. (Also ref #3097 for more discussion on the same topic) |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as spam.
This comment was marked as spam.
-
@arnaud What a great idea you had Thanks !!! @rijkvanzanten We absolutely want that powerful feature !!! I totally agree about breaking changes of a lot of legacy running apps...but if the extended new view feature could be only selected by .env selector or any ui toggler... Then we obsiously take the responsability of messing up the app or not and it won't break anything by default. For my case, I need to integrate an external foreign table from a distant server and I only want to list the content and join some rows with local directus entities. Is that sounds so terrible for you ? Thanks |
Beta Was this translation helpful? Give feedback.
-
We really need this to continue working with directus. |
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
-
I think we must split it up in, at least, two parts. The first one considering only the case in which the views are created outside Directus.
Then take care of collection view only, and not the detail view. Let collection items have no ID but restricting then the possibility of item creation or detail view.
I think it would be a good first step on that will let build upon it.
Enviat des de l'Outlook per a l'iOS<https://aka.ms/o0ukef>
Daniel Valls Estella
Tècnic Especialista
Via Laietana, 33, 4t 1a - 08003 Barcelona
Tel. (+34) 93 291 80 96
***@***.***
www.ambinformacio.cat
La informació inclosa en aquest correu electrònic és CONFIDENCIAL, i és per a ús exclusiu del destinatari. Si vostè llegeix aquest missatge i no n'és el destinatari, li informem que està totalment prohibida la divulgació, distribució o reproducció d'aquesta comunicació, i li demanem que ens ho notifiqui i ens retorni aquest missatge, i a més que l'esborri. Gràcies.
Abans d'imprimir aquest e-mail pensi en el medi ambient.
La información incluida en este correo electrónico es CONFIDENCIAL, siendo para uso exclusivo del destinatario. Si Vd. lee este mensaje y no es el destinatario, le informamos de que está totalmente prohibida la divulgación, distribución o reproducción de este comunicado y le agradeceríamos lo notificara y lo devolviera a la dirección arriba indicada, borrando el mensaje original. Gracias.
Antes de imprimir este e-mail piense en el medio ambiente.
This email and the information within are CONFIDENTIAL and it is intended exclusively for the addressee. If this message has been received in error, you are not entitled to use, disclose, distribute copy or rely on this email in any way. Please notify us immediately by email and delete it from your system.
Please consider the environment before printing this email.
…________________________________
De: Arnaud Leymet ***@***.***>
Enviat el: Wednesday, October 18, 2023 8:53:07 AM
Per a: directus/directus ***@***.***>
A/c: informatica ***@***.***>; Comment ***@***.***>
Tema: Re: [directus/directus] [RFC] Proposal: Support views, materialized views and foreign tables (Discussion #17265)
Sadly, none on my end.
I suspect this matter needs more traction in order for the directus core team to address this challenge.
—
Reply to this email directly, view it on GitHub<#17265 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AT6SGH27XPIPNDEGXTUD6KLX754FHAVCNFSM6AAAAAAUCUQ25OVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TGMJRGQ3DC>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi all, I've been trying to get views in directus as it would enable some essential functionality for the use case I'm working on. I've created some views using raw SQL and tried everything I could to get it recognized as a collection, including modifying the directus_collections and directus_fields tables but wasn't able to get it to work. I get a 403 Forbidden error when trying to access the view's records. It would be great if Directus could at least recognize existing views. Has anyone had success with this? |
Beta Was this translation helpful? Give feedback.
-
Short Summary of Request Review April 18, 2024Generally this is a very, very complex feature and discussion. We will work to break this into more manageable parts.
Lots of great discussion and as always feedback welcome! |
Beta Was this translation helpful? Give feedback.
-
Goal
The general idea is to support views, materialized views and foreign tables as first-class citizens in Directus, and be able to create, query, and CRUD them from Directus.
Features
Use cases
Requirements
Approach
SELECT ROW_NUMBER() OVER() AS id
;General information
Definitions
Vendors support
postgres
mysql
cockroachdb
sqlite3
oracledb
mssql
Proof of concept
Try it out
Support for postgres views has been implemented in the following custom Docker image:
Beta Was this translation helpful? Give feedback.
All reactions