-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable foreign keys with LazyDatabase. #27
Comments
I've currently worked around the issue by enabling FKs every time when selecting/updating/deleting, but this obviously isn't ideal ... |
@bartvanhoutte Thanks for reporting! This is indeed not currently supported and your feature request makes perfect sense. It's my understanding we should probably provide some API to pass arbitrary commands that are executed once the underlying connection is ready or do you think it makes more sense to provide some predefined ones? |
Looking at the amount of options available to be configured this way I think it makes more sense to somehow provide an array of queries to be executed when a connection is made. Something like this would suffice I guess: $options['onConnect'][] = 'PRAGMA foreign_keys = on';
$options['onConnect'][] = 'PRAGMA threads = 4';
$db = (new DatabaseFactory($loop))->openLazy($path, $flags, $options); What do you think? |
Here's my concept for a future $db = new Clue\React\Sqlite\SqliteClient('users.db');
$db->on('open', fn () => $db->exec('PRAGMA foreign_keys = on'));
$db->query('SELECT 1')->then(fn (QueryResult $result) => var_dump($result)); The idea is to fire the What do you think about this? |
Sounds good to me! |
@clue excellent. |
Small support request/possible feature request. I would like to use foreign keys in my SQLite database and according to the SQLite documentation I have to enable this per connection via
PRAGMA foreign_keys = ON
.Is there a way to execute this command everytime LazyDatabase creates a connection to the database?
The text was updated successfully, but these errors were encountered: