示例工程 ch16-bookmarks
ch16-bookmarks/lib/src/data/database.g.dart
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'database.dart';
// ignore_for_file: type=lint
class $BookmarksTable extends Bookmarks
with TableInfo<$BookmarksTable, BookmarkRow> {
@override
final GeneratedDatabase attachedDatabase;
final String? _alias;
$BookmarksTable(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 _titleMeta = const VerificationMeta('title');
@override
late final GeneratedColumn<String> title = GeneratedColumn<String>(
'title',
aliasedName,
false,
additionalChecks: GeneratedColumn.checkTextLength(
minTextLength: 1,
maxTextLength: 200,
),
type: DriftSqlType.string,
requiredDuringInsert: true,
);
static const VerificationMeta _urlMeta = const VerificationMeta('url');
@override
late final GeneratedColumn<String> url = GeneratedColumn<String>(
'url',
aliasedName,
false,
type: DriftSqlType.string,
requiredDuringInsert: true,
);
static const VerificationMeta _noteMeta = const VerificationMeta('note');
@override
late final GeneratedColumn<String> note = GeneratedColumn<String>(
'note',
aliasedName,
false,
type: DriftSqlType.string,
requiredDuringInsert: false,
defaultValue: const Constant(''),
);
static const VerificationMeta _favoriteMeta = const VerificationMeta(
'favorite',
);
@override
late final GeneratedColumn<bool> favorite = GeneratedColumn<bool>(
'favorite',
aliasedName,
false,
type: DriftSqlType.bool,
requiredDuringInsert: false,
defaultConstraints: GeneratedColumn.constraintIsAlways(
'CHECK ("favorite" IN (0, 1))',
),
defaultValue: const Constant(false),
);
static const VerificationMeta _createdAtMeta = const VerificationMeta(
'createdAt',
);
@override
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
'created_at',
aliasedName,
false,
type: DriftSqlType.dateTime,
requiredDuringInsert: false,
defaultValue: currentDateAndTime,
);
@override
List<GeneratedColumn> get $columns => [
id,
title,
url,
note,
favorite,
createdAt,
];
@override
String get aliasedName => _alias ?? actualTableName;
@override
String get actualTableName => $name;
static const String $name = 'bookmarks';
@override
VerificationContext validateIntegrity(
Insertable<BookmarkRow> 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('url')) {
context.handle(
_urlMeta,
url.isAcceptableOrUnknown(data['url']!, _urlMeta),
);
} else if (isInserting) {
context.missing(_urlMeta);
}
if (data.containsKey('note')) {
context.handle(
_noteMeta,
note.isAcceptableOrUnknown(data['note']!, _noteMeta),
);
}
if (data.containsKey('favorite')) {
context.handle(
_favoriteMeta,
favorite.isAcceptableOrUnknown(data['favorite']!, _favoriteMeta),
);
}
if (data.containsKey('created_at')) {
context.handle(
_createdAtMeta,
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta),
);
}
return context;
}
@override
Set<GeneratedColumn> get $primaryKey => {id};
@override
BookmarkRow map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return BookmarkRow(
id: attachedDatabase.typeMapping.read(
DriftSqlType.int,
data['${effectivePrefix}id'],
)!,
title: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}title'],
)!,
url: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}url'],
)!,
note: attachedDatabase.typeMapping.read(
DriftSqlType.string,
data['${effectivePrefix}note'],
)!,
favorite: attachedDatabase.typeMapping.read(
DriftSqlType.bool,
data['${effectivePrefix}favorite'],
)!,
createdAt: attachedDatabase.typeMapping.read(
DriftSqlType.dateTime,
data['${effectivePrefix}created_at'],
)!,
);
}
@override
$BookmarksTable createAlias(String alias) {
return $BookmarksTable(attachedDatabase, alias);
}
}
class BookmarkRow extends DataClass implements Insertable<BookmarkRow> {
final int id;
final String title;
final String url;
final String note;
final bool favorite;
final DateTime createdAt;
const BookmarkRow({
required this.id,
required this.title,
required this.url,
required this.note,
required this.favorite,
required this.createdAt,
});
@override
Map<String, Expression> toColumns(bool nullToAbsent) {
final map = <String, Expression>{};
map['id'] = Variable<int>(id);
map['title'] = Variable<String>(title);
map['url'] = Variable<String>(url);
map['note'] = Variable<String>(note);
map['favorite'] = Variable<bool>(favorite);
map['created_at'] = Variable<DateTime>(createdAt);
return map;
}
BookmarksCompanion toCompanion(bool nullToAbsent) {
return BookmarksCompanion(
id: Value(id),
title: Value(title),
url: Value(url),
note: Value(note),
favorite: Value(favorite),
createdAt: Value(createdAt),
);
}
factory BookmarkRow.fromJson(
Map<String, dynamic> json, {
ValueSerializer? serializer,
}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return BookmarkRow(
id: serializer.fromJson<int>(json['id']),
title: serializer.fromJson<String>(json['title']),
url: serializer.fromJson<String>(json['url']),
note: serializer.fromJson<String>(json['note']),
favorite: serializer.fromJson<bool>(json['favorite']),
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
);
}
@override
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return <String, dynamic>{
'id': serializer.toJson<int>(id),
'title': serializer.toJson<String>(title),
'url': serializer.toJson<String>(url),
'note': serializer.toJson<String>(note),
'favorite': serializer.toJson<bool>(favorite),
'createdAt': serializer.toJson<DateTime>(createdAt),
};
}
BookmarkRow copyWith({
int? id,
String? title,
String? url,
String? note,
bool? favorite,
DateTime? createdAt,
}) => BookmarkRow(
id: id ?? this.id,
title: title ?? this.title,
url: url ?? this.url,
note: note ?? this.note,
favorite: favorite ?? this.favorite,
createdAt: createdAt ?? this.createdAt,
);
BookmarkRow copyWithCompanion(BookmarksCompanion data) {
return BookmarkRow(
id: data.id.present ? data.id.value : this.id,
title: data.title.present ? data.title.value : this.title,
url: data.url.present ? data.url.value : this.url,
note: data.note.present ? data.note.value : this.note,
favorite: data.favorite.present ? data.favorite.value : this.favorite,
createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt,
);
}
@override
String toString() {
return (StringBuffer('BookmarkRow(')
..write('id: $id, ')
..write('title: $title, ')
..write('url: $url, ')
..write('note: $note, ')
..write('favorite: $favorite, ')
..write('createdAt: $createdAt')
..write(')'))
.toString();
}
@override
int get hashCode => Object.hash(id, title, url, note, favorite, createdAt);
@override
bool operator ==(Object other) =>
identical(this, other) ||
(other is BookmarkRow &&
other.id == this.id &&
other.title == this.title &&
other.url == this.url &&
other.note == this.note &&
other.favorite == this.favorite &&
other.createdAt == this.createdAt);
}
class BookmarksCompanion extends UpdateCompanion<BookmarkRow> {
final Value<int> id;
final Value<String> title;
final Value<String> url;
final Value<String> note;
final Value<bool> favorite;
final Value<DateTime> createdAt;
const BookmarksCompanion({
this.id = const Value.absent(),
this.title = const Value.absent(),
this.url = const Value.absent(),
this.note = const Value.absent(),
this.favorite = const Value.absent(),
this.createdAt = const Value.absent(),
});
BookmarksCompanion.insert({
this.id = const Value.absent(),
required String title,
required String url,
this.note = const Value.absent(),
this.favorite = const Value.absent(),
this.createdAt = const Value.absent(),
}) : title = Value(title),
url = Value(url);
static Insertable<BookmarkRow> custom({
Expression<int>? id,
Expression<String>? title,
Expression<String>? url,
Expression<String>? note,
Expression<bool>? favorite,
Expression<DateTime>? createdAt,
}) {
return RawValuesInsertable({
if (id != null) 'id': id,
if (title != null) 'title': title,
if (url != null) 'url': url,
if (note != null) 'note': note,
if (favorite != null) 'favorite': favorite,
if (createdAt != null) 'created_at': createdAt,
});
}
BookmarksCompanion copyWith({
Value<int>? id,
Value<String>? title,
Value<String>? url,
Value<String>? note,
Value<bool>? favorite,
Value<DateTime>? createdAt,
}) {
return BookmarksCompanion(
id: id ?? this.id,
title: title ?? this.title,
url: url ?? this.url,
note: note ?? this.note,
favorite: favorite ?? this.favorite,
createdAt: createdAt ?? this.createdAt,
);
}
@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 (url.present) {
map['url'] = Variable<String>(url.value);
}
if (note.present) {
map['note'] = Variable<String>(note.value);
}
if (favorite.present) {
map['favorite'] = Variable<bool>(favorite.value);
}
if (createdAt.present) {
map['created_at'] = Variable<DateTime>(createdAt.value);
}
return map;
}
@override
String toString() {
return (StringBuffer('BookmarksCompanion(')
..write('id: $id, ')
..write('title: $title, ')
..write('url: $url, ')
..write('note: $note, ')
..write('favorite: $favorite, ')
..write('createdAt: $createdAt')
..write(')'))
.toString();
}
}
abstract class _$AppDatabase extends GeneratedDatabase {
_$AppDatabase(QueryExecutor e) : super(e);
$AppDatabaseManager get managers => $AppDatabaseManager(this);
late final $BookmarksTable bookmarks = $BookmarksTable(this);
@override
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities => [bookmarks];
}
typedef $$BookmarksTableCreateCompanionBuilder = BookmarksCompanion Function({
Value<int> id,
required String title,
required String url,
Value<String> note,
Value<bool> favorite,
Value<DateTime> createdAt,
});
typedef $$BookmarksTableUpdateCompanionBuilder = BookmarksCompanion Function({
Value<int> id,
Value<String> title,
Value<String> url,
Value<String> note,
Value<bool> favorite,
Value<DateTime> createdAt,
});
class $$BookmarksTableFilterComposer
extends Composer<_$AppDatabase, $BookmarksTable> {
$$BookmarksTableFilterComposer({
required super.$db,
required super.$table,
super.joinBuilder,
super.$addJoinBuilderToRootComposer,
super.$removeJoinBuilderFromRootComposer,
});
ColumnFilters<int> get id => $composableBuilder(
column: $table.id,
builder: (column) => ColumnFilters(column),
);
ColumnFilters<String> get title => $composableBuilder(
column: $table.title,
builder: (column) => ColumnFilters(column),
);
ColumnFilters<String> get url => $composableBuilder(
column: $table.url,
builder: (column) => ColumnFilters(column),
);
ColumnFilters<String> get note => $composableBuilder(
column: $table.note,
builder: (column) => ColumnFilters(column),
);
ColumnFilters<bool> get favorite => $composableBuilder(
column: $table.favorite,
builder: (column) => ColumnFilters(column),
);
ColumnFilters<DateTime> get createdAt => $composableBuilder(
column: $table.createdAt,
builder: (column) => ColumnFilters(column),
);
}
class $$BookmarksTableOrderingComposer
extends Composer<_$AppDatabase, $BookmarksTable> {
$$BookmarksTableOrderingComposer({
required super.$db,
required super.$table,
super.joinBuilder,
super.$addJoinBuilderToRootComposer,
super.$removeJoinBuilderFromRootComposer,
});
ColumnOrderings<int> get id => $composableBuilder(
column: $table.id,
builder: (column) => ColumnOrderings(column),
);
ColumnOrderings<String> get title => $composableBuilder(
column: $table.title,
builder: (column) => ColumnOrderings(column),
);
ColumnOrderings<String> get url => $composableBuilder(
column: $table.url,
builder: (column) => ColumnOrderings(column),
);
ColumnOrderings<String> get note => $composableBuilder(
column: $table.note,
builder: (column) => ColumnOrderings(column),
);
ColumnOrderings<bool> get favorite => $composableBuilder(
column: $table.favorite,
builder: (column) => ColumnOrderings(column),
);
ColumnOrderings<DateTime> get createdAt => $composableBuilder(
column: $table.createdAt,
builder: (column) => ColumnOrderings(column),
);
}
class $$BookmarksTableAnnotationComposer
extends Composer<_$AppDatabase, $BookmarksTable> {
$$BookmarksTableAnnotationComposer({
required super.$db,
required super.$table,
super.joinBuilder,
super.$addJoinBuilderToRootComposer,
super.$removeJoinBuilderFromRootComposer,
});
GeneratedColumn<int> get id =>
$composableBuilder(column: $table.id, builder: (column) => column);
GeneratedColumn<String> get title =>
$composableBuilder(column: $table.title, builder: (column) => column);
GeneratedColumn<String> get url =>
$composableBuilder(column: $table.url, builder: (column) => column);
GeneratedColumn<String> get note =>
$composableBuilder(column: $table.note, builder: (column) => column);
GeneratedColumn<bool> get favorite =>
$composableBuilder(column: $table.favorite, builder: (column) => column);
GeneratedColumn<DateTime> get createdAt =>
$composableBuilder(column: $table.createdAt, builder: (column) => column);
}
class $$BookmarksTableTableManager
extends
RootTableManager<
_$AppDatabase,
$BookmarksTable,
BookmarkRow,
$$BookmarksTableFilterComposer,
$$BookmarksTableOrderingComposer,
$$BookmarksTableAnnotationComposer,
$$BookmarksTableCreateCompanionBuilder,
$$BookmarksTableUpdateCompanionBuilder,
(
BookmarkRow,
BaseReferences<_$AppDatabase, $BookmarksTable, BookmarkRow>,
),
BookmarkRow,
PrefetchHooks Function()
> {
$$BookmarksTableTableManager(_$AppDatabase db, $BookmarksTable table)
: super(
TableManagerState(
db: db,
table: table,
createFilteringComposer: () =>
$$BookmarksTableFilterComposer($db: db, $table: table),
createOrderingComposer: () =>
$$BookmarksTableOrderingComposer($db: db, $table: table),
createComputedFieldComposer: () =>
$$BookmarksTableAnnotationComposer($db: db, $table: table),
updateCompanionCallback:
({
Value<int> id = const Value.absent(),
Value<String> title = const Value.absent(),
Value<String> url = const Value.absent(),
Value<String> note = const Value.absent(),
Value<bool> favorite = const Value.absent(),
Value<DateTime> createdAt = const Value.absent(),
}) => BookmarksCompanion(
id: id,
title: title,
url: url,
note: note,
favorite: favorite,
createdAt: createdAt,
),
createCompanionCallback:
({
Value<int> id = const Value.absent(),
required String title,
required String url,
Value<String> note = const Value.absent(),
Value<bool> favorite = const Value.absent(),
Value<DateTime> createdAt = const Value.absent(),
}) => BookmarksCompanion.insert(
id: id,
title: title,
url: url,
note: note,
favorite: favorite,
createdAt: createdAt,
),
withReferenceMapper: (p0) => p0
.map(
(e) => (
e.readTable<$BookmarksTable, BookmarkRow>(table),
BaseReferences<_$AppDatabase, $BookmarksTable, BookmarkRow>(
db,
table,
e,
),
),
)
.toList(),
prefetchHooksCallback: null,
),
);
}
typedef $$BookmarksTableProcessedTableManager =
ProcessedTableManager<
_$AppDatabase,
$BookmarksTable,
BookmarkRow,
$$BookmarksTableFilterComposer,
$$BookmarksTableOrderingComposer,
$$BookmarksTableAnnotationComposer,
$$BookmarksTableCreateCompanionBuilder,
$$BookmarksTableUpdateCompanionBuilder,
(
BookmarkRow,
BaseReferences<_$AppDatabase, $BookmarksTable, BookmarkRow>,
),
BookmarkRow,
PrefetchHooks Function()
>;
class $AppDatabaseManager {
final _$AppDatabase _db;
$AppDatabaseManager(this._db);
$$BookmarksTableTableManager get bookmarks =>
$$BookmarksTableTableManager(_db, _db.bookmarks);
}