Fix generating schema test code

This commit is contained in:
Simon Binder 2022-11-28 21:59:17 +01:00
parent a837e51fda
commit d24644113a
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
22 changed files with 215 additions and 134 deletions

View File

@ -302,6 +302,41 @@ jobs:
working-directory: .
- run: tool/misc_integration_test.sh
migration_integration_tests:
name: "Integration tests for migration tooling"
needs: [compile_sqlite3, dart_dependencies]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- name: Download sqlite3
uses: actions/download-artifact@v2
with:
name: sqlite3
path: /tmp/sqlite/out/
- name: Use downloaded sqlite3
run: |
chmod a+x /tmp/sqlite/out/sqlite3
echo "/tmp/sqlite/out" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/tmp/sqlite/out" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: "${{ env.PUB_CACHE }}"
key: dart-dependencies-${{ needs.dart_dependencies.outputs.dart_version }}-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: |
dart-dependencies-
- run: dart pub global activate melos && melos bootstrap --scope migrations_example
working-directory: .
- name: Run build
run: |
dart run build_runner build
dart run drift_dev schema generate drift_migrations/ test/generated/ --data-classes --companions
dart run drift_dev schema generate drift_migrations/ lib/src/generated
- name: Test
run: dart test
- name: Check that extracting schema still works
run: dart run drift_dev schema dump lib/database.dart drift_migrations/
# upload_coverage:
# runs-on: ubuntu-20.04
# needs: [moor, sqlparser]

View File

@ -1,3 +1,7 @@
## 2.3.1
- Fix invalid code being generated through `drift_dev schema generate`.
## 2.3.0
- Support drift 2.3.x

View File

@ -284,8 +284,6 @@ class TableWriter extends TableOrViewWriter {
..write(emitter.drift('Table'))
..write(' with ')
..write(emitter.drift('TableInfo'));
buffer.write('class ${table.entityInfoName} extends Table with '
'TableInfo');
if (table.isVirtual) {
buffer.write(', ${emitter.drift('VirtualTableInfo')}');
}

View File

@ -1,6 +1,6 @@
name: drift_dev
description: Dev-dependency for users of drift. Contains a the generator and development tools.
version: 2.3.0
version: 2.3.1
repository: https://github.com/simolus3/drift
homepage: https://drift.simonbinder.eu/
issue_tracker: https://github.com/simolus3/drift/issues

View File

@ -171,7 +171,7 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> {
final GeneratedDatabase attachedDatabase;
final String? _alias;
$UsersTable(this.attachedDatabase, [this._alias]);
final VerificationMeta _idMeta = const VerificationMeta('id');
static const VerificationMeta _idMeta = const VerificationMeta('id');
@override
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
@ -180,19 +180,21 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> {
requiredDuringInsert: false,
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
final VerificationMeta _nameMeta = const VerificationMeta('name');
static const VerificationMeta _nameMeta = const VerificationMeta('name');
@override
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string,
requiredDuringInsert: false,
defaultValue: const Constant('name'));
final VerificationMeta _birthdayMeta = const VerificationMeta('birthday');
static const VerificationMeta _birthdayMeta =
const VerificationMeta('birthday');
@override
late final GeneratedColumn<DateTime> birthday = GeneratedColumn<DateTime>(
'birthday', aliasedName, true,
type: DriftSqlType.dateTime, requiredDuringInsert: false);
final VerificationMeta _nextUserMeta = const VerificationMeta('nextUser');
static const VerificationMeta _nextUserMeta =
const VerificationMeta('nextUser');
@override
late final GeneratedColumn<int> nextUser = GeneratedColumn<int>(
'next_user', aliasedName, true,
@ -424,26 +426,27 @@ class Groups extends Table with TableInfo<Groups, Group> {
final GeneratedDatabase attachedDatabase;
final String? _alias;
Groups(this.attachedDatabase, [this._alias]);
final VerificationMeta _idMeta = const VerificationMeta('id');
static const VerificationMeta _idMeta = const VerificationMeta('id');
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
type: DriftSqlType.int,
requiredDuringInsert: false,
$customConstraints: 'NOT NULL');
final VerificationMeta _titleMeta = const VerificationMeta('title');
static const VerificationMeta _titleMeta = const VerificationMeta('title');
late final GeneratedColumn<String> title = GeneratedColumn<String>(
'title', aliasedName, false,
type: DriftSqlType.string,
requiredDuringInsert: true,
$customConstraints: 'NOT NULL');
final VerificationMeta _deletedMeta = const VerificationMeta('deleted');
static const VerificationMeta _deletedMeta =
const VerificationMeta('deleted');
late final GeneratedColumn<bool> deleted = GeneratedColumn<bool>(
'deleted', aliasedName, true,
type: DriftSqlType.bool,
requiredDuringInsert: false,
$customConstraints: 'DEFAULT FALSE',
defaultValue: const CustomExpression('FALSE'));
final VerificationMeta _ownerMeta = const VerificationMeta('owner');
static const VerificationMeta _ownerMeta = const VerificationMeta('owner');
late final GeneratedColumn<int> owner = GeneratedColumn<int>(
'owner', aliasedName, false,
type: DriftSqlType.int,
@ -649,19 +652,20 @@ class Notes extends Table
final GeneratedDatabase attachedDatabase;
final String? _alias;
Notes(this.attachedDatabase, [this._alias]);
final VerificationMeta _titleMeta = const VerificationMeta('title');
static const VerificationMeta _titleMeta = const VerificationMeta('title');
late final GeneratedColumn<String> title = GeneratedColumn<String>(
'title', aliasedName, false,
type: DriftSqlType.string,
requiredDuringInsert: true,
$customConstraints: '');
final VerificationMeta _contentMeta = const VerificationMeta('content');
static const VerificationMeta _contentMeta =
const VerificationMeta('content');
late final GeneratedColumn<String> content = GeneratedColumn<String>(
'content', aliasedName, false,
type: DriftSqlType.string,
requiredDuringInsert: true,
$customConstraints: '');
final VerificationMeta _searchTermsMeta =
static const VerificationMeta _searchTermsMeta =
const VerificationMeta('searchTerms');
late final GeneratedColumn<String> searchTerms = GeneratedColumn<String>(
'search_terms', aliasedName, false,
@ -703,7 +707,7 @@ class Notes extends Table
}
@override
Set<GeneratedColumn> get $primaryKey => const <GeneratedColumn>{};
Set<GeneratedColumn> get $primaryKey => const {};
@override
Note map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
@ -872,7 +876,7 @@ abstract class _$Database extends GeneratedDatabase {
late final Notes notes = Notes(this);
late final GroupCount groupCount = GroupCount(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities =>

View File

@ -9,9 +9,11 @@ class Users extends Table with TableInfo {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
@override
List<GeneratedColumn> get $columns => [id];
@override
@ -36,7 +38,7 @@ class DatabaseAtV1 extends GeneratedDatabase {
DatabaseAtV1.connect(DatabaseConnection c) : super.connect(c);
late final Users users = Users(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities => [users];

View File

@ -9,9 +9,11 @@ class Users extends Table with TableInfo {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string, requiredDuringInsert: true);
@ -39,7 +41,7 @@ class DatabaseAtV2 extends GeneratedDatabase {
DatabaseAtV2.connect(DatabaseConnection c) : super.connect(c);
late final Users users = Users(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities => [users];

View File

@ -9,9 +9,11 @@ class Users extends Table with TableInfo {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string, requiredDuringInsert: true);
@ -90,7 +92,7 @@ class DatabaseAtV3 extends GeneratedDatabase {
late final Users users = Users(this);
late final Groups groups = Groups(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];

View File

@ -9,9 +9,11 @@ class Users extends Table with TableInfo {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string,
@ -92,7 +94,7 @@ class DatabaseAtV4 extends GeneratedDatabase {
late final Users users = Users(this);
late final Groups groups = Groups(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];

View File

@ -9,9 +9,11 @@ class Users extends Table with TableInfo {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string,
@ -21,7 +23,8 @@ class Users extends Table with TableInfo {
'next_user', aliasedName, true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'REFERENCES users (id)');
defaultConstraints:
GeneratedColumn.constraintIsAlways('REFERENCES users (id)'));
@override
List<GeneratedColumn> get $columns => [id, name, nextUser];
@override
@ -141,7 +144,7 @@ class DatabaseAtV5 extends GeneratedDatabase {
late final Groups groups = Groups(this);
late final GroupCount groupCount = GroupCount(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities =>

View File

@ -9,9 +9,11 @@ class Users extends Table with TableInfo {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string,
@ -24,7 +26,8 @@ class Users extends Table with TableInfo {
'next_user', aliasedName, true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'REFERENCES users (id)');
defaultConstraints:
GeneratedColumn.constraintIsAlways('REFERENCES users (id)'));
@override
List<GeneratedColumn> get $columns => [id, name, birthday, nextUser];
@override
@ -148,7 +151,7 @@ class DatabaseAtV6 extends GeneratedDatabase {
late final Groups groups = Groups(this);
late final GroupCount groupCount = GroupCount(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities =>

View File

@ -9,9 +9,11 @@ class Users extends Table with TableInfo {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string,
@ -24,7 +26,8 @@ class Users extends Table with TableInfo {
'next_user', aliasedName, true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'REFERENCES users (id)');
defaultConstraints:
GeneratedColumn.constraintIsAlways('REFERENCES users (id)'));
@override
List<GeneratedColumn> get $columns => [id, name, birthday, nextUser];
@override
@ -168,7 +171,7 @@ class Notes extends Table with TableInfo, VirtualTableInfo {
@override
String get actualTableName => 'notes';
@override
Set<GeneratedColumn> get $primaryKey => const <GeneratedColumn>{};
Set<GeneratedColumn> get $primaryKey => const {};
@override
Never map(Map<String, dynamic> data, {String? tablePrefix}) {
throw UnsupportedError('TableInfo.map in schema verification code');
@ -192,7 +195,7 @@ class DatabaseAtV7 extends GeneratedDatabase {
late final GroupCount groupCount = GroupCount(this);
late final Notes notes = Notes(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities =>

View File

@ -9,9 +9,11 @@ class Users extends Table with TableInfo {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string,
@ -24,7 +26,8 @@ class Users extends Table with TableInfo {
'next_user', aliasedName, true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'REFERENCES "users" ("id")');
defaultConstraints:
GeneratedColumn.constraintIsAlways('REFERENCES "users" ("id")'));
@override
List<GeneratedColumn> get $columns => [id, name, birthday, nextUser];
@override
@ -172,7 +175,7 @@ class Notes extends Table with TableInfo, VirtualTableInfo {
@override
String get actualTableName => 'notes';
@override
Set<GeneratedColumn> get $primaryKey => const <GeneratedColumn>{};
Set<GeneratedColumn> get $primaryKey => const {};
@override
Never map(Map<String, dynamic> data, {String? tablePrefix}) {
throw UnsupportedError('TableInfo.map in schema verification code');
@ -196,7 +199,7 @@ class DatabaseAtV8 extends GeneratedDatabase {
late final GroupCount groupCount = GroupCount(this);
late final Notes notes = Notes(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities =>

View File

@ -98,9 +98,11 @@ class Users extends Table with TableInfo<Users, UsersData> {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
@override
List<GeneratedColumn> get $columns => [id];
@override
@ -113,7 +115,7 @@ class Users extends Table with TableInfo<Users, UsersData> {
UsersData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return UsersData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
);
}
@ -129,7 +131,7 @@ class DatabaseAtV1 extends GeneratedDatabase {
DatabaseAtV1.connect(DatabaseConnection c) : super.connect(c);
late final Users users = Users(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities => [users];

View File

@ -116,9 +116,11 @@ class Users extends Table with TableInfo<Users, UsersData> {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string, requiredDuringInsert: true);
@ -134,9 +136,9 @@ class Users extends Table with TableInfo<Users, UsersData> {
UsersData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return UsersData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
name: attachedDatabase.options.types
name: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
);
}
@ -152,7 +154,7 @@ class DatabaseAtV2 extends GeneratedDatabase {
DatabaseAtV2.connect(DatabaseConnection c) : super.connect(c);
late final Users users = Users(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities => [users];

View File

@ -116,9 +116,11 @@ class Users extends Table with TableInfo<Users, UsersData> {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string, requiredDuringInsert: true);
@ -134,9 +136,9 @@ class Users extends Table with TableInfo<Users, UsersData> {
UsersData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return UsersData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
name: attachedDatabase.options.types
name: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
);
}
@ -348,13 +350,13 @@ class Groups extends Table with TableInfo<Groups, GroupsData> {
GroupsData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return GroupsData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
title: attachedDatabase.options.types
title: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
deleted: attachedDatabase.options.types
deleted: attachedDatabase.typeMapping
.read(DriftSqlType.bool, data['${effectivePrefix}deleted']),
owner: attachedDatabase.options.types
owner: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}owner'])!,
);
}
@ -376,7 +378,7 @@ class DatabaseAtV3 extends GeneratedDatabase {
late final Users users = Users(this);
late final Groups groups = Groups(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];

View File

@ -116,9 +116,11 @@ class Users extends Table with TableInfo<Users, UsersData> {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string,
@ -136,9 +138,9 @@ class Users extends Table with TableInfo<Users, UsersData> {
UsersData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return UsersData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
name: attachedDatabase.options.types
name: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
);
}
@ -350,13 +352,13 @@ class Groups extends Table with TableInfo<Groups, GroupsData> {
GroupsData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return GroupsData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
title: attachedDatabase.options.types
title: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
deleted: attachedDatabase.options.types
deleted: attachedDatabase.typeMapping
.read(DriftSqlType.bool, data['${effectivePrefix}deleted']),
owner: attachedDatabase.options.types
owner: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}owner'])!,
);
}
@ -378,7 +380,7 @@ class DatabaseAtV4 extends GeneratedDatabase {
late final Users users = Users(this);
late final Groups groups = Groups(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];

View File

@ -145,9 +145,11 @@ class Users extends Table with TableInfo<Users, UsersData> {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string,
@ -157,7 +159,8 @@ class Users extends Table with TableInfo<Users, UsersData> {
'next_user', aliasedName, true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'REFERENCES users (id)');
defaultConstraints:
GeneratedColumn.constraintIsAlways('REFERENCES users (id)'));
@override
List<GeneratedColumn> get $columns => [id, name, nextUser];
@override
@ -170,11 +173,11 @@ class Users extends Table with TableInfo<Users, UsersData> {
UsersData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return UsersData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
name: attachedDatabase.options.types
name: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
nextUser: attachedDatabase.options.types
nextUser: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}next_user']),
);
}
@ -386,13 +389,13 @@ class Groups extends Table with TableInfo<Groups, GroupsData> {
GroupsData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return GroupsData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
title: attachedDatabase.options.types
title: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
deleted: attachedDatabase.options.types
deleted: attachedDatabase.typeMapping
.read(DriftSqlType.bool, data['${effectivePrefix}deleted']),
owner: attachedDatabase.options.types
owner: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}owner'])!,
);
}
@ -494,13 +497,13 @@ class GroupCount extends ViewInfo<GroupCount, GroupCountData>
GroupCountData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return GroupCountData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
name: attachedDatabase.options.types
name: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
nextUser: attachedDatabase.options.types
nextUser: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}next_user']),
groupCount: attachedDatabase.options.types
groupCount: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}group_count'])!,
);
}
@ -534,7 +537,7 @@ class DatabaseAtV5 extends GeneratedDatabase {
late final Groups groups = Groups(this);
late final GroupCount groupCount = GroupCount(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities =>

View File

@ -172,9 +172,11 @@ class Users extends Table with TableInfo<Users, UsersData> {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string,
@ -187,7 +189,8 @@ class Users extends Table with TableInfo<Users, UsersData> {
'next_user', aliasedName, true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'REFERENCES users (id)');
defaultConstraints:
GeneratedColumn.constraintIsAlways('REFERENCES users (id)'));
@override
List<GeneratedColumn> get $columns => [id, name, birthday, nextUser];
@override
@ -200,13 +203,13 @@ class Users extends Table with TableInfo<Users, UsersData> {
UsersData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return UsersData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
name: attachedDatabase.options.types
name: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
birthday: attachedDatabase.options.types
birthday: attachedDatabase.typeMapping
.read(DriftSqlType.dateTime, data['${effectivePrefix}birthday']),
nextUser: attachedDatabase.options.types
nextUser: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}next_user']),
);
}
@ -418,13 +421,13 @@ class Groups extends Table with TableInfo<Groups, GroupsData> {
GroupsData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return GroupsData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
title: attachedDatabase.options.types
title: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
deleted: attachedDatabase.options.types
deleted: attachedDatabase.typeMapping
.read(DriftSqlType.bool, data['${effectivePrefix}deleted']),
owner: attachedDatabase.options.types
owner: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}owner'])!,
);
}
@ -535,15 +538,15 @@ class GroupCount extends ViewInfo<GroupCount, GroupCountData>
GroupCountData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return GroupCountData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
name: attachedDatabase.options.types
name: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
birthday: attachedDatabase.options.types
birthday: attachedDatabase.typeMapping
.read(DriftSqlType.dateTime, data['${effectivePrefix}birthday']),
nextUser: attachedDatabase.options.types
nextUser: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}next_user']),
groupCount: attachedDatabase.options.types
groupCount: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}group_count'])!,
);
}
@ -580,7 +583,7 @@ class DatabaseAtV6 extends GeneratedDatabase {
late final Groups groups = Groups(this);
late final GroupCount groupCount = GroupCount(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities =>

View File

@ -172,9 +172,11 @@ class Users extends Table with TableInfo<Users, UsersData> {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string,
@ -187,7 +189,8 @@ class Users extends Table with TableInfo<Users, UsersData> {
'next_user', aliasedName, true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'REFERENCES users (id)');
defaultConstraints:
GeneratedColumn.constraintIsAlways('REFERENCES users (id)'));
@override
List<GeneratedColumn> get $columns => [id, name, birthday, nextUser];
@override
@ -200,13 +203,13 @@ class Users extends Table with TableInfo<Users, UsersData> {
UsersData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return UsersData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
name: attachedDatabase.options.types
name: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
birthday: attachedDatabase.options.types
birthday: attachedDatabase.typeMapping
.read(DriftSqlType.dateTime, data['${effectivePrefix}birthday']),
nextUser: attachedDatabase.options.types
nextUser: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}next_user']),
);
}
@ -418,13 +421,13 @@ class Groups extends Table with TableInfo<Groups, GroupsData> {
GroupsData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return GroupsData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
title: attachedDatabase.options.types
title: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
deleted: attachedDatabase.options.types
deleted: attachedDatabase.typeMapping
.read(DriftSqlType.bool, data['${effectivePrefix}deleted']),
owner: attachedDatabase.options.types
owner: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}owner'])!,
);
}
@ -535,15 +538,15 @@ class GroupCount extends ViewInfo<GroupCount, GroupCountData>
GroupCountData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return GroupCountData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
name: attachedDatabase.options.types
name: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
birthday: attachedDatabase.options.types
birthday: attachedDatabase.typeMapping
.read(DriftSqlType.dateTime, data['${effectivePrefix}birthday']),
nextUser: attachedDatabase.options.types
nextUser: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}next_user']),
groupCount: attachedDatabase.options.types
groupCount: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}group_count'])!,
);
}
@ -735,16 +738,16 @@ class Notes extends Table
@override
String get actualTableName => 'notes';
@override
Set<GeneratedColumn> get $primaryKey => const <GeneratedColumn>{};
Set<GeneratedColumn> get $primaryKey => const {};
@override
NotesData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return NotesData(
title: attachedDatabase.options.types
title: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
content: attachedDatabase.options.types
content: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}content'])!,
searchTerms: attachedDatabase.options.types
searchTerms: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}search_terms'])!,
);
}
@ -767,7 +770,7 @@ class DatabaseAtV7 extends GeneratedDatabase {
late final GroupCount groupCount = GroupCount(this);
late final Notes notes = Notes(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities =>

View File

@ -172,9 +172,11 @@ class Users extends Table with TableInfo<Users, UsersData> {
Users(this.attachedDatabase, [this._alias]);
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
defaultConstraints:
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string,
@ -187,7 +189,8 @@ class Users extends Table with TableInfo<Users, UsersData> {
'next_user', aliasedName, true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: 'REFERENCES "users" ("id")');
defaultConstraints:
GeneratedColumn.constraintIsAlways('REFERENCES "users" ("id")'));
@override
List<GeneratedColumn> get $columns => [id, name, birthday, nextUser];
@override
@ -204,13 +207,13 @@ class Users extends Table with TableInfo<Users, UsersData> {
UsersData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return UsersData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
name: attachedDatabase.options.types
name: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
birthday: attachedDatabase.options.types
birthday: attachedDatabase.typeMapping
.read(DriftSqlType.dateTime, data['${effectivePrefix}birthday']),
nextUser: attachedDatabase.options.types
nextUser: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}next_user']),
);
}
@ -422,13 +425,13 @@ class Groups extends Table with TableInfo<Groups, GroupsData> {
GroupsData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return GroupsData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
title: attachedDatabase.options.types
title: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
deleted: attachedDatabase.options.types
deleted: attachedDatabase.typeMapping
.read(DriftSqlType.bool, data['${effectivePrefix}deleted']),
owner: attachedDatabase.options.types
owner: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}owner'])!,
);
}
@ -539,15 +542,15 @@ class GroupCount extends ViewInfo<GroupCount, GroupCountData>
GroupCountData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return GroupCountData(
id: attachedDatabase.options.types
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
name: attachedDatabase.options.types
name: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
birthday: attachedDatabase.options.types
birthday: attachedDatabase.typeMapping
.read(DriftSqlType.dateTime, data['${effectivePrefix}birthday']),
nextUser: attachedDatabase.options.types
nextUser: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}next_user']),
groupCount: attachedDatabase.options.types
groupCount: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}group_count'])!,
);
}
@ -739,16 +742,16 @@ class Notes extends Table
@override
String get actualTableName => 'notes';
@override
Set<GeneratedColumn> get $primaryKey => const <GeneratedColumn>{};
Set<GeneratedColumn> get $primaryKey => const {};
@override
NotesData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return NotesData(
title: attachedDatabase.options.types
title: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
content: attachedDatabase.options.types
content: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}content'])!,
searchTerms: attachedDatabase.options.types
searchTerms: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}search_terms'])!,
);
}
@ -771,7 +774,7 @@ class DatabaseAtV8 extends GeneratedDatabase {
late final GroupCount groupCount = GroupCount(this);
late final Notes notes = Notes(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities =>

View File

@ -113,14 +113,14 @@ class Users extends Table with TableInfo<Users, User> {
final GeneratedDatabase attachedDatabase;
final String? _alias;
Users(this.attachedDatabase, [this._alias]);
final VerificationMeta _idMeta = const VerificationMeta('id');
static const VerificationMeta _idMeta = const VerificationMeta('id');
late final GeneratedColumn<int> id = GeneratedColumn<int>(
'id', aliasedName, false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
$customConstraints: 'NOT NULL PRIMARY KEY AUTOINCREMENT');
final VerificationMeta _nameMeta = const VerificationMeta('name');
static const VerificationMeta _nameMeta = const VerificationMeta('name');
late final GeneratedColumn<String> name = GeneratedColumn<String>(
'name', aliasedName, false,
type: DriftSqlType.string,
@ -177,7 +177,7 @@ abstract class _$Database extends GeneratedDatabase {
_$Database(QueryExecutor e) : super(e);
late final Users users = Users(this);
@override
Iterable<TableInfo<Table, dynamic>> get allTables =>
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities => [users];