Skip to content
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

UPDATE column value Uint8List cause Unhandled Exception #696

Closed
HXiaoMing opened this issue Sep 13, 2022 · 4 comments
Closed

UPDATE column value Uint8List cause Unhandled Exception #696

HXiaoMing opened this issue Sep 13, 2022 · 4 comments

Comments

@HXiaoMing
Copy link

@entity(tableName: Task.tableName)
class Task {
static const tableName = 'Task';

@PrimaryKey
final int id;

final Uint8List data;

Task(this.id, this.data);

@OverRide
String toString() {
return 'Task{id: $id, len: ${data.length}';
}
}

@dao
abstract class TaskDao {
@query('SELECT * FROM ${Task.tableName} WHERE id = :id')
Future<Task?> findTaskById(int id);

@insert(onConflict: OnConflictStrategy.replace)
Future insertTask(Task task);

@query('UPDATE ${Task.tableName} SET data = :data WHERE id = :id')
Future updateData(Uint8List data, int id);
}

i want to update table Task column data, data type is Uint8List,database type is blob,after execute TaskDao method updateData,data value change to String!!!

after execute method updateData ,and then execute TaskDao method findTaskById occur Unhandled Exception

E/flutter (17057): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'String' is not a subtype of type 'Uint8List' in type cast
E/flutter (17057): #0 _$TaskDao.findTaskById. (package:floor_issue/issue/database.g.dart:117:48)
E/flutter (17057): #1 QueryAdapter.query (package:floor/src/adapter/query_adapter.dart:30:18)
E/flutter (17057):
E/flutter (17057):

source code : https://github.com/HXiaoMing/floor_new_issue.git

@HXiaoMing
Copy link
Author

HXiaoMing commented Sep 13, 2022

image

first click insertTask button

second click updateTask button

then will occur Unhandled Exception

E/flutter (17057): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'String' is not a subtype of type 'Uint8List' in type cast
E/flutter (17057): #0 _$TaskDao.findTaskById. (package:floor_issue/issue/database.g.dart:117:48)
E/flutter (17057): #1 QueryAdapter.query (package:floor/src/adapter/query_adapter.dart:30:18)
E/flutter (17057):
E/flutter (17057):

source code : https://github.com/HXiaoMing/floor_new_issue.git

@dkaera
Copy link
Collaborator

dkaera commented Sep 13, 2022

@HXiaoMing Thank you for reporting the issue. I'll check it today.

@dkaera
Copy link
Collaborator

dkaera commented Sep 13, 2022

Good catch @HXiaoMing, as I see, the value for data field comes as String from sqflite, but should be Uint8List. Try to check this use case with sqflite.

@dkaera
Copy link
Collaborator

dkaera commented Sep 13, 2022

Close this issue as a duplicate of #652
Reopened #652

@dkaera dkaera closed this as completed Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants