You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
: Error: The non-abstract class '$UserJobsTable' is missing implementation
database.dart
// In database.dart
import 'package:drift/drift.dart';
import 'tables/JobConverter.dart';
import 'tables/PostTags.dart';
import 'tables/Posts.dart';
import 'tables/Profiles.dart';
import 'tables/Tags.dart';
import 'tables/Users.dart';
import 'tables/Job.dart';
import 'tables/UserJobs.dart';
part 'generated/database.g.dart';
@DriftDatabase(
tables: [
UserJobs,
Users,
Profiles,
Posts,
Tags,
PostTags,
],
)
class ReflowLocalAppDatabase extends _$ReflowLocalAppDatabase {
ReflowLocalAppDatabase(super.e);
@override
int get schemaVersion => 2;
@override
MigrationStrategy get migration => MigrationStrategy(
onCreate: (Migrator m) => m.createAll(),
onUpgrade: (Migrator m, int from, int to) async {
if (from < 1) {
await m.createTable(profiles);
}
if (from < 1) {
await m.createTable(users);
}
if (from < 1) {
await m.createTable(posts);
}
if (from < 1) {
await m.createTable(tags);
}
if (from < 1) {
await m.createTable(postTags);
}
if (from < 1) {
await m.createTable(userJobs);
}
},
);
}
Error
lib/src/features/experiments/experiments/local_database/services/db/generated/database.g.dart:214:7: Error: The non-abstract class '$UserJobsTable' is missing implementations for these members:
- Table.blob
- Table.boolean
- Table.customConstraints
- Table.customType
- Table.dateTime
- Table.dontWriteConstraints
- Table.int64
- Table.intEnum
- Table.integer
- Table.isStrict
- Table.real
- Table.tableName
- Table.text
- Table.textEnum
- Table.withoutRowId
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
class $UserJobsTable extends UserJobs with TableInfo<$UserJobsTable, UserJobs> {
^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/drift-2.14.1/lib/src/dsl/table.dart:190:28: Context: 'Table.blob' is defined here.
ColumnBuilder<Uint8List> blob() => _isGenerated();
This is the part of database.g.dart which is causing the issue
database.g.dart
class $UserJobsTable extends UserJobs with TableInfo<$UserJobsTable, UserJobs> {
@override
final GeneratedDatabase attachedDatabase;
final String? _alias;
$UserJobsTable(this.attachedDatabase, [this._alias]);
static const VerificationMeta _idMeta = const VerificationMeta('id');
@override
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
@override
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
'user_id', aliasedName, true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints:
GeneratedColumn.constraintIsAlways('REFERENCES users (id)'));
static const VerificationMeta _jobsMeta = const VerificationMeta('jobs');
@override
late final GeneratedColumnWithTypeConverter<List<Job>, String> jobs =
GeneratedColumn<String>('jobs', aliasedName, false,
type: DriftSqlType.string, requiredDuringInsert: true)
.withConverter<List<Job>>($UserJobsTable.$converterjobs);
@override
List<GeneratedColumn> get $columns => [id, userId, jobs];
@override
String get aliasedName => _alias ?? actualTableName;
@override
String get actualTableName => $name;
static const String $name = 'user_jobs';
@override
VerificationContext validateIntegrity(Insertable<UserJobs> instance,
{bool isInserting = false}) {
final context = VerificationContext();
final data = instance.toColumns(true);
if (data.containsKey('id')) {
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
}
if (data.containsKey('user_id')) {
context.handle(_userIdMeta,
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
}
context.handle(_jobsMeta, const VerificationResult.success());
return context;
}
The text was updated successfully, but these errors were encountered:
A data/row class holding a full row of the table in the database.
A companion class holding a partial row, used for updates and inserts.
A hidden table class used by drift to inspect the schema at runtime, used to construct SQL statements and for migration APIs.
The third class needs to extend your existing UserJobs class describing the table. But with the DataClassName annotation, you're telling drift that the name of the first class to generate should be UserJobs as well. So you end up with two identically named classes which is invalid and causes all kinds of errors.
The solution is to either rename the table class (e.g. class UserJobsTable), or to use a different data class name.
BUG
database.dart
Error
This is the part of database.g.dart which is causing the issue
database.g.dart
The text was updated successfully, but these errors were encountered: