Chris Dosé
Chris Dosé
DTDrizzle Team
Created by Chris Dosé on 10/16/2024 in #help
Question about Live Queries and when they update
From my testing, it appears that Live Queries only actually update if the main table being queried from are updated. Is this correct? So if I useLiveQuery with a large relational query that loads a bunch of nested stuff, if any of that nested stuff is updated, I won't get notified. Only if the top level table changes. I'd love to know a little bit more detail about how this all works so that I can better understand in what situations the change listener fires. Is this documented anywhere?
3 replies
DTDrizzle Team
Created by Chris Dosé on 10/16/2024 in #help
[solved] SQLite in expo with useMigrations is failing without any error (just rollback)
I just tried to add a bunch of indexes to my SQLite DB, and the migration consistently fails to apply and I'm not getting any useful error message. Anyone have any ideas or how to better debug this?
LOG Query: CREATE INDEX `person_index` ON `authors` (`url`,`person_id`);
LOG Query:
CREATE INDEX `author_index` ON `book_authors` (`url`,`author_id`);
LOG Query:
CREATE INDEX `book_index` ON `book_authors` (`url`,`book_id`);
LOG Query:
CREATE INDEX `published_index` ON `books` (`published`);
LOG Query:
CREATE INDEX `media_index` ON `local_player_states` (`url`,`media_id`);
LOG Query: ROLLBACK
ERROR Migration error [DrizzleError: Failed to run the query '
CREATE INDEX `book_index` ON `media` (`url`,`book_id`);']
LOG Query: CREATE INDEX `person_index` ON `authors` (`url`,`person_id`);
LOG Query:
CREATE INDEX `author_index` ON `book_authors` (`url`,`author_id`);
LOG Query:
CREATE INDEX `book_index` ON `book_authors` (`url`,`book_id`);
LOG Query:
CREATE INDEX `published_index` ON `books` (`published`);
LOG Query:
CREATE INDEX `media_index` ON `local_player_states` (`url`,`media_id`);
LOG Query: ROLLBACK
ERROR Migration error [DrizzleError: Failed to run the query '
CREATE INDEX `book_index` ON `media` (`url`,`book_id`);']
I had it working for most indexes except two, I thought there was maybe something weird about that table, so I removed those and the rest worked fine. Now after a complete reset (clear app data) and a fresh migration from the ground up, it's failing to create a different index...
2 replies
DTDrizzle Team
Created by Chris Dosé on 10/15/2024 in #help
[solved] useLiveQuery seems to always run the query twice
I'm using drizzle-orm in an expo app and it seems to me (with logging turned on) every instance of useLiveQuery causes the query to happen twice in quick succession. Why is this?
6 replies
DTDrizzle Team
Created by Chris Dosé on 9/29/2024 in #help
Can you get types for results of relational queries?
You can use $inferSelect on the table to get a basic type for the table with all of its columns, but what if you're using a relational query to load some relations and limiting some columns. How do I get the type of the result here?
2 replies
DTDrizzle Team
Created by Chris Dosé on 9/24/2024 in #help
Expo app + drizzle-kit migrations and enabling journal_mode = WAL
Hey, I'm pretty new to SQLite and drizzle-kit. I've read that enabling WAL journal mode on your SQLite DB is preferred for performance. I thought it made sense to create a custom migration npx drizzle-kit generate --custom with this statement in it: PRAGMA journal_mode = WAL; but when I deploy to my device (Android phone) the migration fails to run. Is this not the way I should be doing it?
2 replies