How to specify name of generated dart class for view defined in .drift file #2960
Replies: 1 comment 3 replies
-
Interesting, for tables defined in CREATE TABLE items (
id INT NOT NULL PRIMARY KEY,
description TEXT
) AS ItemEntity; But I suspect something like this does not (yet) exist for Something that is certainly possible right now, is to define your CREATE VIEW my_view WITH ExistingClass AS SELECT ... But of course this is a hassle to maintain. I've tried a few variants using the Ideas (for a possible implementation of this as a new feature)Assuming it does indeed not exist yet, I had the following ideas trying to get it working (i.e. these might make sense in the syntax used throughout Drift files):
CREATE VIEW my_view AS my_view_entity AS SELECT * FROM customers;
CREATE VIEW (my_view AS my_view_entity) AS SELECT * FROM customers;
CREATE VIEW my_view AS SELECT * FROM customers AS my_view_entity; |
Beta Was this translation helpful? Give feedback.
-
I plan to use a convention where by my db entity classes are suffixed with "Entity", but the SQL tables themselves don't need that suffix (it's obvious they're a table :)
I know I can control the name of the generated SQL Table using annotations - however - for my views, I have those defined in .drift files - how do I override how drift names the view classes, so I can add the suffix, independently from the name of the SQL view?
i.e
dart class: CustomerEntity
sql table: customer
sql view (generated by .drift file): customers_with_address
dart class (generated by drift build): CustomersWithAddressEntity
Beta Was this translation helpful? Give feedback.
All reactions