mirror of https://github.com/AMT-Cheif/drift.git
447 lines
13 KiB
Dart
447 lines
13 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
part of 'database.dart';
|
|
|
|
// **************************************************************************
|
|
// MoorGenerator
|
|
// **************************************************************************
|
|
|
|
// ignore_for_file: unnecessary_brace_in_string_interps, unnecessary_this
|
|
class User extends DataClass implements Insertable<User> {
|
|
final int id;
|
|
final String name;
|
|
User({required this.id, required this.name});
|
|
factory User.fromData(Map<String, dynamic> data, {String? prefix}) {
|
|
final effectivePrefix = prefix ?? '';
|
|
return User(
|
|
id: const IntType()
|
|
.mapFromDatabaseResponse(data['${effectivePrefix}id'])!,
|
|
name: const StringType()
|
|
.mapFromDatabaseResponse(data['${effectivePrefix}name'])!,
|
|
);
|
|
}
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['name'] = Variable<String>(name);
|
|
return map;
|
|
}
|
|
|
|
UsersCompanion toCompanion(bool nullToAbsent) {
|
|
return UsersCompanion(
|
|
id: Value(id),
|
|
name: Value(name),
|
|
);
|
|
}
|
|
|
|
factory User.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return User(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
name: serializer.fromJson<String>(json['name']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'name': serializer.toJson<String>(name),
|
|
};
|
|
}
|
|
|
|
User copyWith({int? id, String? name}) => User(
|
|
id: id ?? this.id,
|
|
name: name ?? this.name,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('User(')
|
|
..write('id: $id, ')
|
|
..write('name: $name')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(id, name);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is User && other.id == this.id && other.name == this.name);
|
|
}
|
|
|
|
class UsersCompanion extends UpdateCompanion<User> {
|
|
final Value<int> id;
|
|
final Value<String> name;
|
|
const UsersCompanion({
|
|
this.id = const Value.absent(),
|
|
this.name = const Value.absent(),
|
|
});
|
|
UsersCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
this.name = const Value.absent(),
|
|
});
|
|
static Insertable<User> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? name,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (name != null) 'name': name,
|
|
});
|
|
}
|
|
|
|
UsersCompanion copyWith({Value<int>? id, Value<String>? name}) {
|
|
return UsersCompanion(
|
|
id: id ?? this.id,
|
|
name: name ?? this.name,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (name.present) {
|
|
map['name'] = Variable<String>(name.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UsersCompanion(')
|
|
..write('id: $id, ')
|
|
..write('name: $name')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $UsersTable extends Users with TableInfo<$UsersTable, User> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$UsersTable(this.attachedDatabase, [this._alias]);
|
|
final VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int?> id = GeneratedColumn<int?>(
|
|
'id', aliasedName, false,
|
|
type: const IntType(),
|
|
requiredDuringInsert: false,
|
|
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
|
|
final VerificationMeta _nameMeta = const VerificationMeta('name');
|
|
@override
|
|
late final GeneratedColumn<String?> name = GeneratedColumn<String?>(
|
|
'name', aliasedName, false,
|
|
type: const StringType(),
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('name'));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [id, name];
|
|
@override
|
|
String get aliasedName => _alias ?? 'users';
|
|
@override
|
|
String get actualTableName => 'users';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<User> 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('name')) {
|
|
context.handle(
|
|
_nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
List<Set<GeneratedColumn>> get uniqueKeys => [];
|
|
@override
|
|
User map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
return User.fromData(data,
|
|
prefix: tablePrefix != null ? '$tablePrefix.' : null);
|
|
}
|
|
|
|
@override
|
|
$UsersTable createAlias(String alias) {
|
|
return $UsersTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class Group extends DataClass implements Insertable<Group> {
|
|
final int id;
|
|
final String title;
|
|
final bool? deleted;
|
|
final int owner;
|
|
Group(
|
|
{required this.id,
|
|
required this.title,
|
|
this.deleted,
|
|
required this.owner});
|
|
factory Group.fromData(Map<String, dynamic> data, {String? prefix}) {
|
|
final effectivePrefix = prefix ?? '';
|
|
return Group(
|
|
id: const IntType()
|
|
.mapFromDatabaseResponse(data['${effectivePrefix}id'])!,
|
|
title: const StringType()
|
|
.mapFromDatabaseResponse(data['${effectivePrefix}title'])!,
|
|
deleted: const BoolType()
|
|
.mapFromDatabaseResponse(data['${effectivePrefix}deleted']),
|
|
owner: const IntType()
|
|
.mapFromDatabaseResponse(data['${effectivePrefix}owner'])!,
|
|
);
|
|
}
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['title'] = Variable<String>(title);
|
|
if (!nullToAbsent || deleted != null) {
|
|
map['deleted'] = Variable<bool?>(deleted);
|
|
}
|
|
map['owner'] = Variable<int>(owner);
|
|
return map;
|
|
}
|
|
|
|
GroupsCompanion toCompanion(bool nullToAbsent) {
|
|
return GroupsCompanion(
|
|
id: Value(id),
|
|
title: Value(title),
|
|
deleted: deleted == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(deleted),
|
|
owner: Value(owner),
|
|
);
|
|
}
|
|
|
|
factory Group.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return Group(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
title: serializer.fromJson<String>(json['title']),
|
|
deleted: serializer.fromJson<bool?>(json['deleted']),
|
|
owner: serializer.fromJson<int>(json['owner']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'title': serializer.toJson<String>(title),
|
|
'deleted': serializer.toJson<bool?>(deleted),
|
|
'owner': serializer.toJson<int>(owner),
|
|
};
|
|
}
|
|
|
|
Group copyWith({int? id, String? title, bool? deleted, int? owner}) => Group(
|
|
id: id ?? this.id,
|
|
title: title ?? this.title,
|
|
deleted: deleted ?? this.deleted,
|
|
owner: owner ?? this.owner,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('Group(')
|
|
..write('id: $id, ')
|
|
..write('title: $title, ')
|
|
..write('deleted: $deleted, ')
|
|
..write('owner: $owner')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(id, title, deleted, owner);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is Group &&
|
|
other.id == this.id &&
|
|
other.title == this.title &&
|
|
other.deleted == this.deleted &&
|
|
other.owner == this.owner);
|
|
}
|
|
|
|
class GroupsCompanion extends UpdateCompanion<Group> {
|
|
final Value<int> id;
|
|
final Value<String> title;
|
|
final Value<bool?> deleted;
|
|
final Value<int> owner;
|
|
const GroupsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.title = const Value.absent(),
|
|
this.deleted = const Value.absent(),
|
|
this.owner = const Value.absent(),
|
|
});
|
|
GroupsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required String title,
|
|
this.deleted = const Value.absent(),
|
|
required int owner,
|
|
}) : title = Value(title),
|
|
owner = Value(owner);
|
|
static Insertable<Group> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? title,
|
|
Expression<bool?>? deleted,
|
|
Expression<int>? owner,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (title != null) 'title': title,
|
|
if (deleted != null) 'deleted': deleted,
|
|
if (owner != null) 'owner': owner,
|
|
});
|
|
}
|
|
|
|
GroupsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<String>? title,
|
|
Value<bool?>? deleted,
|
|
Value<int>? owner}) {
|
|
return GroupsCompanion(
|
|
id: id ?? this.id,
|
|
title: title ?? this.title,
|
|
deleted: deleted ?? this.deleted,
|
|
owner: owner ?? this.owner,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (title.present) {
|
|
map['title'] = Variable<String>(title.value);
|
|
}
|
|
if (deleted.present) {
|
|
map['deleted'] = Variable<bool?>(deleted.value);
|
|
}
|
|
if (owner.present) {
|
|
map['owner'] = Variable<int>(owner.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('GroupsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('title: $title, ')
|
|
..write('deleted: $deleted, ')
|
|
..write('owner: $owner')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class Groups extends Table with TableInfo<Groups, Group> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
Groups(this.attachedDatabase, [this._alias]);
|
|
final VerificationMeta _idMeta = const VerificationMeta('id');
|
|
late final GeneratedColumn<int?> id = GeneratedColumn<int?>(
|
|
'id', aliasedName, false,
|
|
type: const IntType(),
|
|
requiredDuringInsert: false,
|
|
$customConstraints: 'NOT NULL');
|
|
final VerificationMeta _titleMeta = const VerificationMeta('title');
|
|
late final GeneratedColumn<String?> title = GeneratedColumn<String?>(
|
|
'title', aliasedName, false,
|
|
type: const StringType(),
|
|
requiredDuringInsert: true,
|
|
$customConstraints: 'NOT NULL');
|
|
final VerificationMeta _deletedMeta = const VerificationMeta('deleted');
|
|
late final GeneratedColumn<bool?> deleted = GeneratedColumn<bool?>(
|
|
'deleted', aliasedName, true,
|
|
type: const BoolType(),
|
|
requiredDuringInsert: false,
|
|
$customConstraints: 'DEFAULT FALSE',
|
|
defaultValue: const CustomExpression<bool>('FALSE'));
|
|
final VerificationMeta _ownerMeta = const VerificationMeta('owner');
|
|
late final GeneratedColumn<int?> owner = GeneratedColumn<int?>(
|
|
'owner', aliasedName, false,
|
|
type: const IntType(),
|
|
requiredDuringInsert: true,
|
|
$customConstraints: 'NOT NULL REFERENCES users (id)');
|
|
@override
|
|
List<GeneratedColumn> get $columns => [id, title, deleted, owner];
|
|
@override
|
|
String get aliasedName => _alias ?? 'groups';
|
|
@override
|
|
String get actualTableName => 'groups';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<Group> 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('title')) {
|
|
context.handle(
|
|
_titleMeta, title.isAcceptableOrUnknown(data['title']!, _titleMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_titleMeta);
|
|
}
|
|
if (data.containsKey('deleted')) {
|
|
context.handle(_deletedMeta,
|
|
deleted.isAcceptableOrUnknown(data['deleted']!, _deletedMeta));
|
|
}
|
|
if (data.containsKey('owner')) {
|
|
context.handle(
|
|
_ownerMeta, owner.isAcceptableOrUnknown(data['owner']!, _ownerMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_ownerMeta);
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
List<Set<GeneratedColumn>> get uniqueKeys => [];
|
|
@override
|
|
Group map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
return Group.fromData(data,
|
|
prefix: tablePrefix != null ? '$tablePrefix.' : null);
|
|
}
|
|
|
|
@override
|
|
Groups createAlias(String alias) {
|
|
return Groups(attachedDatabase, alias);
|
|
}
|
|
|
|
@override
|
|
List<String> get customConstraints => const ['PRIMARY KEY (id)'];
|
|
@override
|
|
bool get dontWriteConstraints => true;
|
|
}
|
|
|
|
abstract class _$Database extends GeneratedDatabase {
|
|
_$Database(QueryExecutor e) : super(SqlTypeSystem.defaultInstance, e);
|
|
_$Database.connect(DatabaseConnection c) : super.connect(c);
|
|
late final $UsersTable users = $UsersTable(this);
|
|
late final Groups groups = Groups(this);
|
|
@override
|
|
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
|
@override
|
|
List<DatabaseSchemaEntity> get allSchemaEntities => [users, groups];
|
|
}
|