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)
- Drift generator doesn't strip custom row class from SQL HOT 1
- Primary Key not required in companion insert HOT 2
- Issue with generated code: database.g.dart file HOT 29
- Select int64 return type HOT 4
- Start a select with the Dart API without specifiying a table HOT 4
- Custom query generated type missing nullables HOT 4
- [WEB] DriftRemoteException: RangeError (start): Invalid value: Not in inclusive range 0..2322399232: -1972640192 HOT 1
- createdAt & updatedAt columns HOT 4
- SqliteException(5): while selecting from statement, database is locked, database is locked (code 5) HOT 2
- drift files: file formatting impossible
- How to initialize the database without the constructor syntax HOT 2
- Add toJson() for result class HOT 1
- Query stream cancellations can affect migrations
- No modification allowed Error HOT 4
- Schema migration helper fails when there are no migrations yet HOT 1
- Views code generation HOT 9
- Cannot test migrations using modular approach with store_date_time_values_as_text: true HOT 4
- Unable to override `runs_before` in `build.yaml` due to `Unrecognized keys` exception HOT 2
- Support remote SQLite databases HOT 8
- drift_flutter package doesn't exist HOT 3
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.