From dcf09b55d89d4946cebcde9b83e1c79b94b3208e Mon Sep 17 00:00:00 2001 From: David Martos Date: Mon, 2 Mar 2020 20:46:43 +0100 Subject: [PATCH] Expose underlying db in encrypted moor --- extras/encryption/lib/encrypted_moor.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/extras/encryption/lib/encrypted_moor.dart b/extras/encryption/lib/encrypted_moor.dart index 30071825..7d1dd909 100644 --- a/extras/encryption/lib/encrypted_moor.dart +++ b/extras/encryption/lib/encrypted_moor.dart @@ -194,4 +194,20 @@ class EncryptedExecutor extends DelegatedDatabase { creator: creator, password: password), logStatements: logStatements); + + /// The underlying sqflite [s.Database] object used by moor to send queries. + /// + /// Using the sqflite database can cause unexpected behavior in moor. For + /// instance, stream queries won't update for updates sent to the [s.Database] + /// directly. + /// For this reason, projects shouldn't use this getter unless they absolutely + /// need to. The database is exposed to make migrating from sqflite to moor + /// easier. + /// + /// Note that this returns null until the moor database has been opened. + /// A moor database is opened lazily when the first query runs. + s.Database get sqfliteDb { + final sqfliteDelegate = delegate as _SqfliteDelegate; + return sqfliteDelegate.db; + } }