我需要你的帮助,我正在使用 moor 作为数据库创建一个带有颤振的待办事项应用程序,我在我的数据库中创建了三个表,但只有两个关心我的问题,它们是任务和项目。然后当我尝试插入一个新任务我得到了这个错误
发生异常。SqliteException(SqliteException:外键不匹配 - “任务”引用“项目”,SQL 逻辑错误)
有我的项目表
class Projects extends Table {
IntColumn get id => integer().autoIncrement()();
IntColumn get tasksNumber => integer()();
TextColumn get projectName => text().withLength(min: 2, max: 32)();
TextColumn get description => text().withLength(min: 2, max: 35)();
DateTimeColumn get dateAndTime =>dateTime().withDefault(Constant(DateTime.now()))();
BoolColumn get isCompleted => boolean().withDefault(Constant(false))();
@override
Set<Column> get primaryKey => {id, projectName};
}
任务之一是
class Tasks extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get project =>text().customConstraint('REFERENCES projects(projectName)')();
TextColumn get taskName => text().withLength(min: 2, max: 32)();
DateTimeColumn get dateAndTime =>dateTime().withDefault(Constant(DateTime.now()))();
BoolColumn get isDone => boolean().withDefault(Constant(false))();
@override
Set<Column> get primaryKey => {id, taskName, project};
}
谢谢你的帮助