我在 SQFLITE 的 onCreate 方法上添加了这个。我需要生成一个自动增量 ID。我打印了 id 但值为空。如何使用 sqflite 添加自动增量 ID?
await db.execute(
"""CREATE TABLE submitRequestTable(id INTEGER PRIMARY KEY AUTOINCREMENT,equipmentId INTEGER, woDescriptionId INTEGER, details STRING, priorityId INTEGER,
workTypeId INTEGER, sourceId INTEGER, filename STRING, isOffline INTEGER, systemDate STRING, username STRING, subItemId INTEGER, status STRING)""");
}
我像这样存储数据。我没有将 id 添加到值中。我没有将值传递给 id。
storeSubmitRequest(
BuildContext context,
int equipmentId,
int woDescriptionId,
String details,
int priorityId,
int workTypeId,
int sourceId,
String filename,
int isOffline,
String systemDate,
String username,
int subItemId,
String status) async {
var db = await db1;
Batch batch = db.batch();
var data = SubmitRequestModel(
equipmentId: equipmentId,
woDescriptionId: woDescriptionId,
details: details,
priorityId: priorityId,
workTypeId: workTypeId,
sourceId: sourceId,
filename: filename,
isOffline: isOffline,
systemDate: systemDate,
username: username,
subItemId: subItemId,
status: status);
batch.insert(
'submitRequestTable',
data.toJson(),
// conflictAlgorithm: ConflictAlgorithm.replace,
);
await batch.commit();
Navigator.push(
context, MaterialPageRoute(builder: (context) => ListPage("")));
}