drift icon indicating copy to clipboard operation
drift copied to clipboard

[SQLParser] ATTACH DATABASE supported ?

Open MobiliteDev opened this issue 4 years ago • 3 comments

Is it possible with SQLParser to support ATTACH SQLite function ?

MobiliteDev avatar Apr 26 '21 09:04 MobiliteDev

Can you describe your use case for analyzing ATTACH statements? At the moment the analyzer doesn't check schema names at all (so something like SELECT * FROM foo.bar would fail). How much of the schema support do you need?

simolus3 avatar Apr 26 '21 10:04 simolus3

My future mobile app will have at less 5 databases.

Each database will have between 100 and 600 tables, each table between 10 and 600 fields, that's huge, but I can't make differently. So, sometimes, I will need to attach until 5 databases at the same time, and query them with join clauses.

How much of the schema support do you need?

Honestly, I don't know for the moment but I think I will want to use the maximum as possible of SQLite capabilities.

MobiliteDev avatar Apr 26 '21 12:04 MobiliteDev

What you need is big data for mobile! Joke apart, I don't know your exact use case but I would first consider to review the data structure of your app and try to make something more scalable . If you cannot then I'd probably consider using sqflite directly without using a layer like moor. You will probably want the raw sqlite capabilities without adding more overhead.

gsouf avatar May 23 '21 09:05 gsouf

Another use case which i am running into is having CMS exported database for offline first stored on a CDN, and a User database that possibly could be encrypted referencing the readonly database.

Example:

CMS DB (Read only): songs, albums, artwork

USER DB: playlists, likes, history

This would allow network updates of the CMS DB in the background and the user DB is created per account on device

I have done some testing with sqlite3 and can get it to work

rodydavis avatar Sep 14 '23 17:09 rodydavis

The use case Rody described sounds pretty interesting, but it would require broader support for different schemas in core drift as well. I'm happy to have a discussion about the requirements and scope for that, but it should probably be done in a new issue.

sqlparser has supported the schema field in table references for a while now, but we don't (and likely won't) support ATTACH statements unless there is a community contribution for it - I don't need that parser functionality for drift files. So I'll close this one as being done, but we can continue the discussion about multi-schema support.

simolus3 avatar Sep 16 '23 15:09 simolus3