FormatException on TextColumn
After migrating to Drift 2.7.0 and WasmSqlite3.loadFromUrl, occasionally getting the below error in Sentry on production on Chrome. This is new.
FormatException: 1234 Blahblahblah Road, Qwertyqwerty, Asdfasdf 12345, United States
Field is defined as:
TextColumn get location => text()();
Implementation:
Future<Database> openDatabase({bool logStatements = false}) async {
IndexedDbFileSystem fs = await IndexedDbFileSystem.open(dbName: 'db');
WasmSqlite3 sqlite = await WasmSqlite3.loadFromUrl(
Uri.parse('sqlite3.wasm'),
environment: SqliteEnvironment(fileSystem: fs),
);
return Database(
WasmDatabase(
sqlite3: sqlite,
path: '/app.db',
logStatements: logStatements,
),
);
}
minified:lj: FormatException: 1234 Blahblahblah Road, Qwertyqwerty, Asdfasdf 12345, United States
at A.e(org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_helper.dart:1128:37)
at A.dr(org-dartlang-sdk:///lib/_internal/js_runtime/lib/core_patch.dart:174:5)
at A.bK.prototype.ca(../../../../../../.pub-cache/hosted/pub.dev/drift-2.7.0/lib/src/runtime/types/mapping.dart:147:20)
at A.lT.prototype.r8(../../../lib/core/database/database.g.dart:2704:12)
at A.lT.prototype.H4(../../../lib/core/database/database.g.dart:2682:8)
at A.c_o(org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_helper.dart:2236:9)
at MapAndAwait|mapAsyncAndAwait.{<anonymous function>#2}.aRD.prototype.$0(../../../../../../.pub-cache/hosted/pub.dev/drift-2.7.0/lib/src/utils/async.dart:10:53)
at A.QD(org-dartlang-sdk:///lib/async/future.dart:302:20)
at A.aRE.prototype.$1(../../../../../../.pub-cache/hosted/pub.dev/drift-2.7.0/lib/src/utils/async.dart:10:35)
at MappedListIterable.length.V.prototype.cQ(org-dartlang-sdk:///lib/internal/iterable.dart:415:31)
That exception indicates that drift attempted to interpret a string column as an integer.
Looking at lib/core/database/database.g.dart:2704:12, does it seem correct to you that the column gets interpreted as an integer there? Essentially, the question is whether this is a bug in the generated code or another form of the corrupted database problem.
@simolus3 :2704 is indeed an int column, but it's one column after the right column. The correct column for this to be inserted in was the one before, at line :2702, a string column. There is no possible way we tried to insert it to the :2704 column, so no idea how it's getting out of order like that.
Recompiled database.g.dart on 2.7.0 just to make sure nothing crazy was going on there and there's no change.
Without the source code to reproduce this we have no way to fix it. I'm closing this issue for now, we'll reopen if we can get something to help us fix it