https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
g

grahamborland

09/21/2023, 11:46 AM
Does SQLDelight give me a way to access a list of table names in the schema? Looking at the generated database class, it contains a bunch of calls to the driver with the
CREATE TABLE
statements, but nothing like a plain list of table names. Would any of SQLDelight’s Gradle tasks help me generate this list, or do I need to do my own schema parsing?
d

Derek Ellis

09/21/2023, 12:02 PM
It might differ if you're not using SQLite, but you could write a SQL query that gets you a list of all the tables?
Copy code
SELECT name FROM sqlite_master WHERE type='table';
g

grahamborland

09/21/2023, 12:08 PM
Thanks, I thought about that, but that may not work for my use case if the database hasn’t been created (or migrated) yet. I really need it to be generated at build time.
d

Derek Ellis

09/21/2023, 8:05 PM
Ah I see. There's nothing like that in SQLDelight today, but there is a very broad idea of potentially creating some kind of SQLDelight plugin API where you could create plugins for the SQLDelight compiler/codegen to do custom things which could hypothetically accomplish this kind of thing. It's not actively being worked on at the moment though.
👍 1
2 Views