mirror of https://github.com/AMT-Cheif/drift.git
193 lines
5.6 KiB
Dart
193 lines
5.6 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
part of 'main.dart';
|
|
|
|
// ignore_for_file: type=lint
|
|
class $UsersTable extends Users with TableInfo<$UsersTable, User> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$UsersTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<UuidValue> id = GeneratedColumn<UuidValue>(
|
|
'id', aliasedName, false,
|
|
type: PgTypes.uuid,
|
|
requiredDuringInsert: false,
|
|
defaultValue: genRandomUuid());
|
|
static const VerificationMeta _nameMeta = const VerificationMeta('name');
|
|
@override
|
|
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
|
'name', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
@override
|
|
List<GeneratedColumn> get $columns => [id, name];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = '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));
|
|
} else if (isInserting) {
|
|
context.missing(_nameMeta);
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => const {};
|
|
@override
|
|
User map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return User(
|
|
id: attachedDatabase.typeMapping
|
|
.read(PgTypes.uuid, data['${effectivePrefix}id'])!,
|
|
name: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$UsersTable createAlias(String alias) {
|
|
return $UsersTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class User extends DataClass implements Insertable<User> {
|
|
final UuidValue id;
|
|
final String name;
|
|
const User({required this.id, required this.name});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<UuidValue>(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<UuidValue>(json['id']),
|
|
name: serializer.fromJson<String>(json['name']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<UuidValue>(id),
|
|
'name': serializer.toJson<String>(name),
|
|
};
|
|
}
|
|
|
|
User copyWith({UuidValue? 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<UuidValue> id;
|
|
final Value<String> name;
|
|
final Value<int> rowid;
|
|
const UsersCompanion({
|
|
this.id = const Value.absent(),
|
|
this.name = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
});
|
|
UsersCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required String name,
|
|
this.rowid = const Value.absent(),
|
|
}) : name = Value(name);
|
|
static Insertable<User> custom({
|
|
Expression<UuidValue>? id,
|
|
Expression<String>? name,
|
|
Expression<int>? rowid,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (name != null) 'name': name,
|
|
if (rowid != null) 'rowid': rowid,
|
|
});
|
|
}
|
|
|
|
UsersCompanion copyWith(
|
|
{Value<UuidValue>? id, Value<String>? name, Value<int>? rowid}) {
|
|
return UsersCompanion(
|
|
id: id ?? this.id,
|
|
name: name ?? this.name,
|
|
rowid: rowid ?? this.rowid,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<UuidValue>(id.value, PgTypes.uuid);
|
|
}
|
|
if (name.present) {
|
|
map['name'] = Variable<String>(name.value);
|
|
}
|
|
if (rowid.present) {
|
|
map['rowid'] = Variable<int>(rowid.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UsersCompanion(')
|
|
..write('id: $id, ')
|
|
..write('name: $name, ')
|
|
..write('rowid: $rowid')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
abstract class _$DriftPostgresDatabase extends GeneratedDatabase {
|
|
_$DriftPostgresDatabase(QueryExecutor e) : super(e);
|
|
late final $UsersTable users = $UsersTable(this);
|
|
@override
|
|
Iterable<TableInfo<Table, Object?>> get allTables =>
|
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
|
@override
|
|
List<DatabaseSchemaEntity> get allSchemaEntities => [users];
|
|
}
|