Comments (4)
Drift is not parsing custom queries. The problem are the double quotes around "Brazil"
. We compile sqlite3 with the recommended options, which means that things in double quotes are interpreted as references (so sqlite3 tries to search for a column named Brazil and then aborts the query because no such column exists). To use strings in SQL, use single quotes ('Brazil'
).
To enable legacy support for double-quoted string literals, add a setup
parameter to NativeDatabase
that calls rawDb.config.doubleQuotedStringLiterals = true
.
from drift.
I poked around the repo trying to identify the issue but nothing sticks out to me here.
Might this be a parser issue? Super confusing why it complains no such column: Brazil
when my query is:
SELECT * FROM customers WHERE "Country" = "Brazil";
One more thing, the SELECT
works without a WHERE
clause.
from drift.
@simolus3 thanks for your suggestion. That worked like a charm for Native. However I'm targeting web so this is how I got my setup working inside if web.dart
.
DatabaseConnection connect() {
return DatabaseConnection.delayed(Future(() async {
final result = await WasmDatabase.open(
databaseName: 'main',
sqlite3Uri: Uri.parse('sqlite3.wasm'),
driftWorkerUri: Uri.parse('drift_worker.js'),
initializeDatabase: () async {
final data = await rootBundle.load('assets/chinook.db');
return data.buffer.asUint8List();
},
);
if (result.missingFeatures.isNotEmpty) {
debugPrint('Using ${result.chosenImplementation} due to unsupported '
'browser features: ${result.missingFeatures}');
}
return result.resolvedExecutor;
}));
}
Could you make a suggestion for this setup? Poking around inside of wasm.dart
here I didn't see how I might do the same thing.
Forgive me if I missed it. Also thanks so much for your work!
from drift.
Doing this on the web is a little tricky because your app doesn't own the database, it just accesses it through a separate worker (drift_worker.js
). We can't sent closures to workers, so no similar API exists.
You can write your own worker that calls WasmDatabase.workerMainForOpen()
which takes a similar callback used to configure all databases opened by that worker. The file could look similar to this one, except that it would add the callback.
You can compile your own worker with dart compile js -O4 web/worker.dart
, or automatically with build_runner
by adding a dependency on build_web_compilers
(that is also what the example app is doing so that I don't have to manually copy the compiled worker into it, see this build configuration for a starting point).
from drift.
Related Issues (20)
- Share db with host Android app embedded flutter readonly/read write problems HOT 5
- disk I/O error
- `enableMigrations` param for web implementation. HOT 1
- feat: Common Root Manager Operations should work with id
- postgresql arrays? HOT 7
- Error while trying to run in flutter web HOT 1
- Upsert against db object behaves differently to upsert against batch HOT 2
- Allow QueryInterceptor to ignore/exclude specified tables HOT 1
- Converting database keys in toJson from camelCase to snake_case HOT 1
- LazyDatabase is imposible to execute queries when reopen HOT 1
- flutter web unable to build HOT 1
- No `SqliteException` thrown if when fetching data from non existent column in test mode HOT 4
- Can't compile to wasm HOT 1
- [web] TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm' HOT 1
- SqliteException(1): while preparing a statement, unrecognized token: "@" HOT 3
- Database can no longer be mocked with new manager API HOT 10
- [Documentation] Insufficient documentation and examples on complex migration HOT 1
- Ability to mark foreign key constraint as deferrable HOT 1
- Schema verifier fails in setting DatabaseConfig.doubleQuotedStringLiterals HOT 4
- Flutter not resolving
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drift.