fix: Drop invalid SetNull and SetDefault test models (#165)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Marcelo Mendonça Soares <marcelomendoncasoares@users.noreply.github.com>
This commit is contained in:
Marcelo Mendonça Soares 2026-10-08 18:21:10 -03:00 • committed by GitHub
commit e12c9dc9f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 21344 additions and 4036 deletions

View file

@ -291,7 +291,6 @@ class DemoDebugEndpoint extends Endpoint {
await add<Organization>();
await add<Company>();
await add<RestrictChild>();
await add<RequiredSetNullChild>();
await add<Unique>();
await add<UniqueUuid>();
await add<UniqueComposite>();

View file

@ -1,754 +0,0 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: dead_code, unnecessary_null_comparison
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod/serverpod.dart' as _is;
import 'package:serverpod_offline_sync_test_server/src/generated/protocol.dart'
as _ixxccm81;
import 'person.dart' as _iensfz4m;
abstract class NullableSetDefaultChild
implements _is.TableRow<_is.UuidValue?>, _is.ProtocolSerialization {
NullableSetDefaultChild._({
this.id,
this.spaceId,
required this.name,
this.parentId,
this.parent,
});
factory NullableSetDefaultChild({
_is.UuidValue? id,
int? spaceId,
required String name,
_is.UuidValue? parentId,
_iensfz4m.Person? parent,
}) = _NullableSetDefaultChildImpl;
factory NullableSetDefaultChild.fromJson(
Map<String, dynamic> jsonSerialization,
) {
return NullableSetDefaultChild(
id: jsonSerialization['id'] == null
? null
: _is.UuidValueJsonExtension.fromJson(jsonSerialization['id']),
spaceId: jsonSerialization['spaceId'] as int?,
name: jsonSerialization['name'] as String,
parentId: jsonSerialization['parentId'] == null
? null
: _is.UuidValueJsonExtension.fromJson(jsonSerialization['parentId']),
parent: jsonSerialization['parent'] == null
? null
: _ixxccm81.Protocol().deserialize<_iensfz4m.Person>(
jsonSerialization['parent'],
),
);
}
static final t = NullableSetDefaultChildTable();
static const db = NullableSetDefaultChildRepository._();
@override
_is.UuidValue? id;
/// The space owning this row. Maintained by the sync engine.
int? spaceId;
String name;
_is.UuidValue? parentId;
_iensfz4m.Person? parent;
@override
_is.Table<_is.UuidValue?> get table => t;
/// Returns a shallow copy of this [NullableSetDefaultChild]
/// with some or all fields replaced by the given arguments.
@_is.useResult
NullableSetDefaultChild copyWith({
_is.UuidValue? id,
int? spaceId,
String? name,
_is.UuidValue? parentId,
_iensfz4m.Person? parent,
});
@override
Map<String, dynamic> toJson() {
return {
'__className__': 'NullableSetDefaultChild',
if (id != null) 'id': id?.toJson(),
if (spaceId != null) 'spaceId': spaceId,
'name': name,
if (parentId != null) 'parentId': parentId?.toJson(),
if (parent != null) 'parent': parent?.toJson(),
};
}
@override
Map<String, dynamic> toJsonForProtocol() {
return {
'__className__': 'NullableSetDefaultChild',
if (id != null) 'id': id?.toJson(),
if (spaceId != null) 'spaceId': spaceId,
'name': name,
if (parentId != null) 'parentId': parentId?.toJson(),
if (parent != null) 'parent': parent?.toJsonForProtocol(),
};
}
static NullableSetDefaultChildInclude include({
_iensfz4m.PersonInclude? parent,
}) {
return NullableSetDefaultChildInclude._(parent: parent);
}
static NullableSetDefaultChildIncludeList includeList({
_is.WhereExpressionBuilder<NullableSetDefaultChildTable>? where,
int? limit,
int? offset,
_is.OrderByBuilder<NullableSetDefaultChildTable>? orderBy,
_is.OrderByListBuilder<NullableSetDefaultChildTable>? orderByList,
NullableSetDefaultChildInclude? include,
}) {
return NullableSetDefaultChildIncludeList._(
where: where,
limit: limit,
offset: offset,
orderBy: orderBy?.call(NullableSetDefaultChild.t),
orderByList: orderByList?.call(NullableSetDefaultChild.t),
include: include,
);
}
@override
String toString() {
return _is.SerializationManager.encode(this);
}
}
class _Undefined {}
class _NullableSetDefaultChildImpl extends NullableSetDefaultChild {
_NullableSetDefaultChildImpl({
_is.UuidValue? id,
int? spaceId,
required String name,
_is.UuidValue? parentId,
_iensfz4m.Person? parent,
}) : super._(
id: id,
spaceId: spaceId,
name: name,
parentId: parentId,
parent: parent,
);
/// Returns a shallow copy of this [NullableSetDefaultChild]
/// with some or all fields replaced by the given arguments.
@_is.useResult
@override
NullableSetDefaultChild copyWith({
Object? id = _Undefined,
Object? spaceId = _Undefined,
String? name,
Object? parentId = _Undefined,
Object? parent = _Undefined,
}) {
return NullableSetDefaultChild(
id: id is _is.UuidValue? ? id : this.id,
spaceId: spaceId is int? ? spaceId : this.spaceId,
name: name ?? this.name,
parentId: parentId is _is.UuidValue? ? parentId : this.parentId,
parent: parent is _iensfz4m.Person? ? parent : this.parent?.copyWith(),
);
}
}
class NullableSetDefaultChildUpdateTable
extends _is.UpdateTable<NullableSetDefaultChildTable> {
NullableSetDefaultChildUpdateTable(super.table);
_is.ColumnValue<int, int> spaceId(int? value) => _is.ColumnValue(
table.spaceId,
value,
);
_is.ColumnValue<String, String> name(String value) => _is.ColumnValue(
table.name,
value,
);
_is.ColumnValue<_is.UuidValue, _is.UuidValue> parentId(
_is.UuidValue? value,
) => _is.ColumnValue(
table.parentId,
value,
);
}
class NullableSetDefaultChildTable extends _is.Table<_is.UuidValue?> {
NullableSetDefaultChildTable({super.tableRelation})
: super(tableName: 'nullable_set_default_child') {
updateTable = NullableSetDefaultChildUpdateTable(this);
spaceId = _is.ColumnInt(
'spaceId',
this,
);
name = _is.ColumnString(
'name',
this,
);
parentId = _is.ColumnUuid(
'parentId',
this,
);
}
late final NullableSetDefaultChildUpdateTable updateTable;
/// The space owning this row. Maintained by the sync engine.
late final _is.ColumnInt spaceId;
late final _is.ColumnString name;
late final _is.ColumnUuid parentId;
_iensfz4m.PersonTable? _parent;
_iensfz4m.PersonTable get parent {
if (_parent != null) return _parent!;
_parent = _is.createRelationTable(
relationFieldName: 'parent',
field: NullableSetDefaultChild.t.parentId,
foreignField: _iensfz4m.Person.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_iensfz4m.PersonTable(tableRelation: foreignTableRelation),
);
return _parent!;
}
@override
List<_is.Column> get columns => [
id,
spaceId,
name,
parentId,
];
@override
_is.Table? getRelationTable(String relationField) {
if (relationField == 'parent') {
return parent;
}
return null;
}
}
class NullableSetDefaultChildInclude extends _is.IncludeObject {
NullableSetDefaultChildInclude._({_iensfz4m.PersonInclude? parent}) {
_parent = parent;
}
_iensfz4m.PersonInclude? _parent;
@override
Map<String, _is.Include?> get includes => {'parent': _parent};
@override
_is.Table<_is.UuidValue?> get table => NullableSetDefaultChild.t;
}
class NullableSetDefaultChildIncludeList extends _is.IncludeList {
NullableSetDefaultChildIncludeList._({
_is.WhereExpressionBuilder<NullableSetDefaultChildTable>? where,
super.limit,
super.offset,
super.orderBy,
super.orderByList,
super.include,
}) {
super.where = where?.call(NullableSetDefaultChild.t);
}
@override
Map<String, _is.Include?> get includes => include?.includes ?? {};
@override
_is.Table<_is.UuidValue?> get table => NullableSetDefaultChild.t;
}
class NullableSetDefaultChildRepository {
const NullableSetDefaultChildRepository._();
final attachRow = const NullableSetDefaultChildAttachRowRepository._();
final detachRow = const NullableSetDefaultChildDetachRowRepository._();
/// Returns a list of [NullableSetDefaultChild]s matching the given query parameters.
///
/// Use [where] to specify which items to include in the return value.
/// If none is specified, all items will be returned.
///
/// To specify the order of the items use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// The maximum number of items can be set by [limit]. If no limit is set,
/// all items matching the query will be returned.
///
/// [offset] defines how many items to skip, after which [limit] (or all)
/// items are read from the database.
///
/// ```dart
/// var persons = await Persons.db.find(
/// session,
/// where: (t) => t.lastName.equals('Jones'),
/// orderBy: (t) => t.firstName,
/// limit: 100,
/// );
/// ```
Future<List<NullableSetDefaultChild>> find(
_is.DatabaseSession session, {
_is.WhereExpressionBuilder<NullableSetDefaultChildTable>? where,
int? limit,
int? offset,
_is.OrderByBuilder<NullableSetDefaultChildTable>? orderBy,
_is.OrderByListBuilder<NullableSetDefaultChildTable>? orderByList,
_is.Transaction? transaction,
NullableSetDefaultChildInclude? include,
_is.LockMode? lockMode,
_is.LockBehavior? lockBehavior,
}) async {
return session.db.find<NullableSetDefaultChild>(
where: where?.call(NullableSetDefaultChild.t),
orderBy: orderBy?.call(NullableSetDefaultChild.t),
orderByList: orderByList?.call(NullableSetDefaultChild.t),
limit: limit,
offset: offset,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Returns the first matching [NullableSetDefaultChild] matching the given query parameters.
///
/// Use [where] to specify which items to include in the return value.
/// If none is specified, all items will be returned.
///
/// To specify the order use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// [offset] defines how many items to skip, after which the next one will be picked.
///
/// ```dart
/// var youngestPerson = await Persons.db.findFirstRow(
/// session,
/// where: (t) => t.lastName.equals('Jones'),
/// orderBy: (t) => t.age,
/// );
/// ```
Future<NullableSetDefaultChild?> findFirstRow(
_is.DatabaseSession session, {
_is.WhereExpressionBuilder<NullableSetDefaultChildTable>? where,
int? offset,
_is.OrderByBuilder<NullableSetDefaultChildTable>? orderBy,
_is.OrderByListBuilder<NullableSetDefaultChildTable>? orderByList,
_is.Transaction? transaction,
NullableSetDefaultChildInclude? include,
_is.LockMode? lockMode,
_is.LockBehavior? lockBehavior,
}) async {
return session.db.findFirstRow<NullableSetDefaultChild>(
where: where?.call(NullableSetDefaultChild.t),
orderBy: orderBy?.call(NullableSetDefaultChild.t),
orderByList: orderByList?.call(NullableSetDefaultChild.t),
offset: offset,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Finds a single [NullableSetDefaultChild] by its [id] or null if no such row exists.
Future<NullableSetDefaultChild?> findById(
_is.DatabaseSession session,
_is.UuidValue id, {
_is.Transaction? transaction,
NullableSetDefaultChildInclude? include,
_is.LockMode? lockMode,
_is.LockBehavior? lockBehavior,
}) async {
return session.db.findById<NullableSetDefaultChild>(
id,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Inserts all [NullableSetDefaultChild]s in the list and returns the inserted rows.
///
/// The returned [NullableSetDefaultChild]s will have their `id` fields set.
///
/// This is an atomic operation, meaning that if one of the rows fails to
/// insert, none of the rows will be inserted.
///
/// If [ignoreConflicts] is set to `true`, rows that conflict with existing
/// rows are silently skipped, and only the successfully inserted rows are
/// returned.
///
/// If [noReturn] is set to `true`, the inserted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<NullableSetDefaultChild>> insert(
_is.DatabaseSession session,
List<NullableSetDefaultChild> rows, {
_is.Transaction? transaction,
bool ignoreConflicts = false,
bool noReturn = false,
}) async {
return session.db.insert<NullableSetDefaultChild>(
rows,
transaction: transaction,
ignoreConflicts: ignoreConflicts,
noReturn: noReturn,
);
}
/// Inserts a single [NullableSetDefaultChild] and returns the inserted row.
///
/// The returned [NullableSetDefaultChild] will have its `id` field set.
Future<NullableSetDefaultChild> insertRow(
_is.DatabaseSession session,
NullableSetDefaultChild row, {
_is.Transaction? transaction,
}) async {
return session.db.insertRow<NullableSetDefaultChild>(
row,
transaction: transaction,
);
}
/// Upserts all [NullableSetDefaultChild]s in the list and returns the resulting rows.
///
/// If a row conflicts on the given [conflictColumns], the existing row is
/// updated with the new values. Otherwise, a new row is inserted.
///
/// If [updateColumns] is provided, only those columns will be updated on
/// conflict. If null, all non-conflict, non-id columns are updated.
///
/// If [updateWhere] is provided, the update only applies to rows matching the
/// given expression. Conflicting rows that don't match are skipped and not
/// returned, so the resulting list may be shorter than [rows].
///
/// The returned [NullableSetDefaultChild]s will have their `id` fields set.
///
/// This is an atomic operation, meaning that if one of the rows fails,
/// none of the rows will be affected.
///
/// If [noReturn] is set to `true`, the resulting rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<NullableSetDefaultChild>> upsert(
_is.DatabaseSession session,
List<NullableSetDefaultChild> rows, {
required _is.ColumnSelections<NullableSetDefaultChildTable> conflictColumns,
_is.ColumnSelections<NullableSetDefaultChildTable>? updateColumns,
_is.WhereExpressionBuilder<NullableSetDefaultChildTable>? updateWhere,
_is.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.upsert<NullableSetDefaultChild>(
rows,
conflictColumns: conflictColumns(NullableSetDefaultChild.t),
updateColumns: updateColumns?.call(NullableSetDefaultChild.t),
updateWhere: updateWhere?.call(NullableSetDefaultChild.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Upserts a single [NullableSetDefaultChild] and returns the resulting row.
///
/// If the row conflicts on the given [conflictColumns], the existing row is
/// updated. Otherwise, a new row is inserted.
///
/// If [updateColumns] is provided, only those columns will be updated on
/// conflict. If null, all non-conflict, non-id columns are updated.
///
/// If [updateWhere] is provided, the update only applies when the existing
/// row matches the expression. Returns `null` if no row was affected — for
/// example when [updateWhere] does not match the conflicting row.
///
/// The returned [NullableSetDefaultChild] will have its `id` field set.
Future<NullableSetDefaultChild?> upsertRow(
_is.DatabaseSession session,
NullableSetDefaultChild row, {
required _is.ColumnSelections<NullableSetDefaultChildTable> conflictColumns,
_is.ColumnSelections<NullableSetDefaultChildTable>? updateColumns,
_is.WhereExpressionBuilder<NullableSetDefaultChildTable>? updateWhere,
_is.Transaction? transaction,
}) async {
return session.db.upsertRow<NullableSetDefaultChild>(
row,
conflictColumns: conflictColumns(NullableSetDefaultChild.t),
updateColumns: updateColumns?.call(NullableSetDefaultChild.t),
updateWhere: updateWhere?.call(NullableSetDefaultChild.t),
transaction: transaction,
);
}
/// Updates all [NullableSetDefaultChild]s in the list and returns the updated rows. If
/// [columns] is provided, only those columns will be updated. Defaults to
/// all columns.
/// This is an atomic operation, meaning that if one of the rows fails to
/// update, none of the rows will be updated.
///
/// If [noReturn] is set to `true`, the updated rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<NullableSetDefaultChild>> update(
_is.DatabaseSession session,
List<NullableSetDefaultChild> rows, {
_is.ColumnSelections<NullableSetDefaultChildTable>? columns,
_is.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.update<NullableSetDefaultChild>(
rows,
columns: columns?.call(NullableSetDefaultChild.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Updates a single [NullableSetDefaultChild]. The row needs to have its id set.
/// Optionally, a list of [columns] can be provided to only update those
/// columns. Defaults to all columns.
Future<NullableSetDefaultChild> updateRow(
_is.DatabaseSession session,
NullableSetDefaultChild row, {
_is.ColumnSelections<NullableSetDefaultChildTable>? columns,
_is.Transaction? transaction,
}) async {
return session.db.updateRow<NullableSetDefaultChild>(
row,
columns: columns?.call(NullableSetDefaultChild.t),
transaction: transaction,
);
}
/// Updates a single [NullableSetDefaultChild] by its [id] with the specified [columnValues].
/// Returns the updated row or null if no row with the given id exists.
Future<NullableSetDefaultChild?> updateById(
_is.DatabaseSession session,
_is.UuidValue id, {
required _is.ColumnValueListBuilder<NullableSetDefaultChildUpdateTable>
columnValues,
_is.Transaction? transaction,
}) async {
return session.db.updateById<NullableSetDefaultChild>(
id,
columnValues: columnValues(NullableSetDefaultChild.t.updateTable),
transaction: transaction,
);
}
/// Updates all [NullableSetDefaultChild]s matching the [where] expression with the specified [columnValues].
/// Returns the list of updated rows.
///
/// If [noReturn] is set to `true`, the updated rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<NullableSetDefaultChild>> updateWhere(
_is.DatabaseSession session, {
required _is.ColumnValueListBuilder<NullableSetDefaultChildUpdateTable>
columnValues,
required _is.WhereExpressionBuilder<NullableSetDefaultChildTable> where,
int? limit,
int? offset,
_is.OrderByBuilder<NullableSetDefaultChildTable>? orderBy,
_is.OrderByListBuilder<NullableSetDefaultChildTable>? orderByList,
_is.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.updateWhere<NullableSetDefaultChild>(
columnValues: columnValues(NullableSetDefaultChild.t.updateTable),
where: where(NullableSetDefaultChild.t),
limit: limit,
offset: offset,
orderBy: orderBy?.call(NullableSetDefaultChild.t),
orderByList: orderByList?.call(NullableSetDefaultChild.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Deletes all [NullableSetDefaultChild]s in the list and returns the deleted rows.
///
/// To specify the order of the returned rows use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// This is an atomic operation, meaning that if one of the rows fail to
/// be deleted, none of the rows will be deleted.
///
/// If [noReturn] is set to `true`, the deleted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<NullableSetDefaultChild>> delete(
_is.DatabaseSession session,
List<NullableSetDefaultChild> rows, {
_is.OrderByBuilder<NullableSetDefaultChildTable>? orderBy,
_is.OrderByListBuilder<NullableSetDefaultChildTable>? orderByList,
_is.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.delete<NullableSetDefaultChild>(
rows,
orderBy: orderBy?.call(NullableSetDefaultChild.t),
orderByList: orderByList?.call(NullableSetDefaultChild.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Deletes a single [NullableSetDefaultChild].
Future<NullableSetDefaultChild> deleteRow(
_is.DatabaseSession session,
NullableSetDefaultChild row, {
_is.Transaction? transaction,
}) async {
return session.db.deleteRow<NullableSetDefaultChild>(
row,
transaction: transaction,
);
}
/// Deletes all rows matching the [where] expression.
///
/// To specify the order of the returned rows use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// If [noReturn] is set to `true`, the deleted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<NullableSetDefaultChild>> deleteWhere(
_is.DatabaseSession session, {
required _is.WhereExpressionBuilder<NullableSetDefaultChildTable> where,
_is.OrderByBuilder<NullableSetDefaultChildTable>? orderBy,
_is.OrderByListBuilder<NullableSetDefaultChildTable>? orderByList,
_is.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.deleteWhere<NullableSetDefaultChild>(
where: where(NullableSetDefaultChild.t),
orderBy: orderBy?.call(NullableSetDefaultChild.t),
orderByList: orderByList?.call(NullableSetDefaultChild.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Counts the number of rows matching the [where] expression. If omitted,
/// will return the count of all rows in the table.
Future<int> count(
_is.DatabaseSession session, {
_is.WhereExpressionBuilder<NullableSetDefaultChildTable>? where,
int? limit,
_is.Transaction? transaction,
}) async {
return session.db.count<NullableSetDefaultChild>(
where: where?.call(NullableSetDefaultChild.t),
limit: limit,
transaction: transaction,
);
}
/// Acquires row-level locks on [NullableSetDefaultChild] rows matching the [where] expression.
Future<void> lockRows(
_is.DatabaseSession session, {
required _is.WhereExpressionBuilder<NullableSetDefaultChildTable> where,
required _is.LockMode lockMode,
required _is.Transaction transaction,
_is.LockBehavior lockBehavior = _is.LockBehavior.wait,
}) async {
return session.db.lockRows<NullableSetDefaultChild>(
where: where(NullableSetDefaultChild.t),
lockMode: lockMode,
lockBehavior: lockBehavior,
transaction: transaction,
);
}
}
class NullableSetDefaultChildAttachRowRepository {
const NullableSetDefaultChildAttachRowRepository._();
/// Creates a relation between the given [NullableSetDefaultChild] and [Person]
/// by setting the [NullableSetDefaultChild]'s foreign key `parentId` to refer to the [Person].
Future<void> parent(
_is.DatabaseSession session,
NullableSetDefaultChild nullableSetDefaultChild,
_iensfz4m.Person parent, {
_is.Transaction? transaction,
}) async {
if (nullableSetDefaultChild.id == null) {
throw ArgumentError.notNull('nullableSetDefaultChild.id');
}
if (parent.id == null) {
throw ArgumentError.notNull('parent.id');
}
var $nullableSetDefaultChild = nullableSetDefaultChild.copyWith(
parentId: parent.id,
);
await session.db.updateRow<NullableSetDefaultChild>(
$nullableSetDefaultChild,
columns: [NullableSetDefaultChild.t.parentId],
transaction: transaction,
);
}
}
class NullableSetDefaultChildDetachRowRepository {
const NullableSetDefaultChildDetachRowRepository._();
/// Detaches the relation between this [NullableSetDefaultChild] and the [Person] set in `parent`
/// by setting the [NullableSetDefaultChild]'s foreign key `parentId` to `null`.
///
/// This removes the association between the two models without deleting
/// the related record.
Future<void> parent(
_is.DatabaseSession session,
NullableSetDefaultChild nullableSetDefaultChild, {
_is.Transaction? transaction,
}) async {
if (nullableSetDefaultChild.id == null) {
throw ArgumentError.notNull('nullableSetDefaultChild.id');
}
var $nullableSetDefaultChild = nullableSetDefaultChild.copyWith(
parentId: null,
);
await session.db.updateRow<NullableSetDefaultChild>(
$nullableSetDefaultChild,
columns: [NullableSetDefaultChild.t.parentId],
transaction: transaction,
);
}
}

View file

@ -31,12 +31,10 @@ import 'fk_chain/set_null_cascade_child.dart' as _ideurard;
import 'fk_chain/set_null_middle.dart' as _icv70ksq;
import 'fk_chain/set_null_restrict_child.dart' as _ix62gjf0;
import 'fk_chain/set_null_set_null_child.dart' as _ihkyqxiw;
import 'nullable_set_default_child.dart' as _i6rvg9xd;
import 'organization.dart' as _irjtvpke;
import 'person.dart' as _iensfz4m;
import 'required_cascade_child.dart' as _ivx9jyda;
import 'required_no_action_child.dart' as _itlfbi2f;
import 'required_set_null_child.dart' as _i1huw131;
import 'restrict_child.dart' as _isrf0aof;
import 'sync_document.dart' as _ix6xayzv;
import 'town.dart' as _iytblq2r;
@ -67,12 +65,10 @@ export 'fk_chain/set_null_cascade_child.dart';
export 'fk_chain/set_null_middle.dart';
export 'fk_chain/set_null_restrict_child.dart';
export 'fk_chain/set_null_set_null_child.dart';
export 'nullable_set_default_child.dart';
export 'organization.dart';
export 'person.dart';
export 'required_cascade_child.dart';
export 'required_no_action_child.dart';
export 'required_set_null_child.dart';
export 'restrict_child.dart';
export 'sync_document.dart';
export 'town.dart';
@ -777,64 +773,6 @@ class Protocol extends _is.DatabaseSerializationManager {
indexes: [],
managed: true,
),
_isp.TableDefinition(
name: 'nullable_set_default_child',
dartName: 'NullableSetDefaultChild',
schema: 'public',
module: 'serverpod_offline_sync_test',
columns: [
_isp.ColumnDefinition(
name: 'id',
columnType: _isp.ColumnType.uuid,
isNullable: false,
dartType: 'UuidValue?',
columnDefault: 'random_v7',
),
_isp.ColumnDefinition(
name: 'spaceId',
columnType: _isp.ColumnType.bigint,
isNullable: true,
dartType: 'int?',
),
_isp.ColumnDefinition(
name: 'name',
columnType: _isp.ColumnType.text,
isNullable: false,
dartType: 'String',
),
_isp.ColumnDefinition(
name: 'parentId',
columnType: _isp.ColumnType.uuid,
isNullable: true,
dartType: 'UuidValue?',
),
],
foreignKeys: [
_isp.ForeignKeyDefinition(
constraintName: 'nullable_set_default_child_fk_0',
columns: ['spaceId'],
referenceTable: 'offline_sync_spaces',
referenceTableSchema: 'public',
referenceColumns: ['id'],
onUpdate: _isp.ForeignKeyAction.noAction,
onDelete: _isp.ForeignKeyAction.cascade,
matchType: null,
),
_isp.ForeignKeyDefinition(
constraintName: 'nullable_set_default_child_fk_1',
columns: ['parentId'],
referenceTable: 'person',
referenceTableSchema: 'public',
referenceColumns: ['id'],
onUpdate: _isp.ForeignKeyAction.noAction,
onDelete: _isp.ForeignKeyAction.setDefault,
matchType: null,
deferrable: _isp.DeferrableConstraint.initiallyDeferred,
),
],
indexes: [],
managed: true,
),
_isp.TableDefinition(
name: 'organization',
dartName: 'Organization',
@ -1106,64 +1044,6 @@ class Protocol extends _is.DatabaseSerializationManager {
indexes: [],
managed: true,
),
_isp.TableDefinition(
name: 'required_set_null_child',
dartName: 'RequiredSetNullChild',
schema: 'public',
module: 'serverpod_offline_sync_test',
columns: [
_isp.ColumnDefinition(
name: 'id',
columnType: _isp.ColumnType.uuid,
isNullable: false,
dartType: 'UuidValue?',
columnDefault: 'random_v7',
),
_isp.ColumnDefinition(
name: 'spaceId',
columnType: _isp.ColumnType.bigint,
isNullable: true,
dartType: 'int?',
),
_isp.ColumnDefinition(
name: 'name',
columnType: _isp.ColumnType.text,
isNullable: false,
dartType: 'String',
),
_isp.ColumnDefinition(
name: 'parentId',
columnType: _isp.ColumnType.uuid,
isNullable: false,
dartType: 'UuidValue',
),
],
foreignKeys: [
_isp.ForeignKeyDefinition(
constraintName: 'required_set_null_child_fk_0',
columns: ['spaceId'],
referenceTable: 'offline_sync_spaces',
referenceTableSchema: 'public',
referenceColumns: ['id'],
onUpdate: _isp.ForeignKeyAction.noAction,
onDelete: _isp.ForeignKeyAction.cascade,
matchType: null,
),
_isp.ForeignKeyDefinition(
constraintName: 'required_set_null_child_fk_1',
columns: ['parentId'],
referenceTable: 'person',
referenceTableSchema: 'public',
referenceColumns: ['id'],
onUpdate: _isp.ForeignKeyAction.noAction,
onDelete: _isp.ForeignKeyAction.setNull,
matchType: null,
deferrable: _isp.DeferrableConstraint.initiallyDeferred,
),
],
indexes: [],
managed: true,
),
_isp.TableDefinition(
name: 'restrict_child',
dartName: 'RestrictChild',
@ -2449,9 +2329,6 @@ class Protocol extends _is.DatabaseSerializationManager {
if (t == _ihkyqxiw.FkChainSetNullSetNullChild) {
return _ihkyqxiw.FkChainSetNullSetNullChild.fromJson(data) as T;
}
if (t == _i6rvg9xd.NullableSetDefaultChild) {
return _i6rvg9xd.NullableSetDefaultChild.fromJson(data) as T;
}
if (t == _irjtvpke.Organization) {
return _irjtvpke.Organization.fromJson(data) as T;
}
@ -2464,9 +2341,6 @@ class Protocol extends _is.DatabaseSerializationManager {
if (t == _itlfbi2f.RequiredNoActionChild) {
return _itlfbi2f.RequiredNoActionChild.fromJson(data) as T;
}
if (t == _i1huw131.RequiredSetNullChild) {
return _i1huw131.RequiredSetNullChild.fromJson(data) as T;
}
if (t == _isrf0aof.RestrictChild) {
return _isrf0aof.RestrictChild.fromJson(data) as T;
}
@ -2581,12 +2455,6 @@ class Protocol extends _is.DatabaseSerializationManager {
: null)
as T;
}
if (t == _is.getType<_i6rvg9xd.NullableSetDefaultChild?>()) {
return (data != null
? _i6rvg9xd.NullableSetDefaultChild.fromJson(data)
: null)
as T;
}
if (t == _is.getType<_irjtvpke.Organization?>()) {
return (data != null ? _irjtvpke.Organization.fromJson(data) : null) as T;
}
@ -2605,12 +2473,6 @@ class Protocol extends _is.DatabaseSerializationManager {
: null)
as T;
}
if (t == _is.getType<_i1huw131.RequiredSetNullChild?>()) {
return (data != null
? _i1huw131.RequiredSetNullChild.fromJson(data)
: null)
as T;
}
if (t == _is.getType<_isrf0aof.RestrictChild?>()) {
return (data != null ? _isrf0aof.RestrictChild.fromJson(data) : null)
as T;
@ -2754,12 +2616,10 @@ class Protocol extends _is.DatabaseSerializationManager {
_icv70ksq.FkChainSetNullMiddle => 'FkChainSetNullMiddle',
_ix62gjf0.FkChainSetNullRestrictChild => 'FkChainSetNullRestrictChild',
_ihkyqxiw.FkChainSetNullSetNullChild => 'FkChainSetNullSetNullChild',
_i6rvg9xd.NullableSetDefaultChild => 'NullableSetDefaultChild',
_irjtvpke.Organization => 'Organization',
_iensfz4m.Person => 'Person',
_ivx9jyda.RequiredCascadeChild => 'RequiredCascadeChild',
_itlfbi2f.RequiredNoActionChild => 'RequiredNoActionChild',
_i1huw131.RequiredSetNullChild => 'RequiredSetNullChild',
_isrf0aof.RestrictChild => 'RestrictChild',
_ix6xayzv.SyncDocument => 'SyncDocument',
_iytblq2r.Town => 'Town',
@ -2819,8 +2679,6 @@ class Protocol extends _is.DatabaseSerializationManager {
return 'FkChainSetNullRestrictChild';
case _ihkyqxiw.FkChainSetNullSetNullChild():
return 'FkChainSetNullSetNullChild';
case _i6rvg9xd.NullableSetDefaultChild():
return 'NullableSetDefaultChild';
case _irjtvpke.Organization():
return 'Organization';
case _iensfz4m.Person():
@ -2829,8 +2687,6 @@ class Protocol extends _is.DatabaseSerializationManager {
return 'RequiredCascadeChild';
case _itlfbi2f.RequiredNoActionChild():
return 'RequiredNoActionChild';
case _i1huw131.RequiredSetNullChild():
return 'RequiredSetNullChild';
case _isrf0aof.RestrictChild():
return 'RestrictChild';
case _ix6xayzv.SyncDocument():
@ -2935,9 +2791,6 @@ class Protocol extends _is.DatabaseSerializationManager {
if (dataClassName == 'FkChainSetNullSetNullChild') {
return deserialize<_ihkyqxiw.FkChainSetNullSetNullChild>(data['data']);
}
if (dataClassName == 'NullableSetDefaultChild') {
return deserialize<_i6rvg9xd.NullableSetDefaultChild>(data['data']);
}
if (dataClassName == 'Organization') {
return deserialize<_irjtvpke.Organization>(data['data']);
}
@ -2950,9 +2803,6 @@ class Protocol extends _is.DatabaseSerializationManager {
if (dataClassName == 'RequiredNoActionChild') {
return deserialize<_itlfbi2f.RequiredNoActionChild>(data['data']);
}
if (dataClassName == 'RequiredSetNullChild') {
return deserialize<_i1huw131.RequiredSetNullChild>(data['data']);
}
if (dataClassName == 'RestrictChild') {
return deserialize<_isrf0aof.RestrictChild>(data['data']);
}
@ -3092,8 +2942,6 @@ class Protocol extends _is.DatabaseSerializationManager {
return _ix62gjf0.FkChainSetNullRestrictChild.t;
case _ihkyqxiw.FkChainSetNullSetNullChild:
return _ihkyqxiw.FkChainSetNullSetNullChild.t;
case _i6rvg9xd.NullableSetDefaultChild:
return _i6rvg9xd.NullableSetDefaultChild.t;
case _irjtvpke.Organization:
return _irjtvpke.Organization.t;
case _iensfz4m.Person:
@ -3102,8 +2950,6 @@ class Protocol extends _is.DatabaseSerializationManager {
return _ivx9jyda.RequiredCascadeChild.t;
case _itlfbi2f.RequiredNoActionChild:
return _itlfbi2f.RequiredNoActionChild.t;
case _i1huw131.RequiredSetNullChild:
return _i1huw131.RequiredSetNullChild.t;
case _isrf0aof.RestrictChild:
return _isrf0aof.RestrictChild.t;
case _iytblq2r.Town:

View file

@ -1,723 +0,0 @@
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
/* To generate run: "serverpod generate" */
// ignore_for_file: implementation_imports
// ignore_for_file: library_private_types_in_public_api
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: public_member_api_docs
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters
// ignore_for_file: invalid_use_of_internal_member
// ignore_for_file: dead_code, unnecessary_null_comparison
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod/serverpod.dart' as _is;
import 'package:serverpod_offline_sync_test_server/src/generated/protocol.dart'
as _ixxccm81;
import 'person.dart' as _iensfz4m;
abstract class RequiredSetNullChild
implements _is.TableRow<_is.UuidValue?>, _is.ProtocolSerialization {
RequiredSetNullChild._({
this.id,
this.spaceId,
required this.name,
required this.parentId,
this.parent,
});
factory RequiredSetNullChild({
_is.UuidValue? id,
int? spaceId,
required String name,
required _is.UuidValue parentId,
_iensfz4m.Person? parent,
}) = _RequiredSetNullChildImpl;
factory RequiredSetNullChild.fromJson(
Map<String, dynamic> jsonSerialization,
) {
return RequiredSetNullChild(
id: jsonSerialization['id'] == null
? null
: _is.UuidValueJsonExtension.fromJson(jsonSerialization['id']),
spaceId: jsonSerialization['spaceId'] as int?,
name: jsonSerialization['name'] as String,
parentId: _is.UuidValueJsonExtension.fromJson(
jsonSerialization['parentId'],
),
parent: jsonSerialization['parent'] == null
? null
: _ixxccm81.Protocol().deserialize<_iensfz4m.Person>(
jsonSerialization['parent'],
),
);
}
static final t = RequiredSetNullChildTable();
static const db = RequiredSetNullChildRepository._();
@override
_is.UuidValue? id;
/// The space owning this row. Maintained by the sync engine.
int? spaceId;
String name;
_is.UuidValue parentId;
_iensfz4m.Person? parent;
@override
_is.Table<_is.UuidValue?> get table => t;
/// Returns a shallow copy of this [RequiredSetNullChild]
/// with some or all fields replaced by the given arguments.
@_is.useResult
RequiredSetNullChild copyWith({
_is.UuidValue? id,
int? spaceId,
String? name,
_is.UuidValue? parentId,
_iensfz4m.Person? parent,
});
@override
Map<String, dynamic> toJson() {
return {
'__className__': 'RequiredSetNullChild',
if (id != null) 'id': id?.toJson(),
if (spaceId != null) 'spaceId': spaceId,
'name': name,
'parentId': parentId.toJson(),
if (parent != null) 'parent': parent?.toJson(),
};
}
@override
Map<String, dynamic> toJsonForProtocol() {
return {
'__className__': 'RequiredSetNullChild',
if (id != null) 'id': id?.toJson(),
if (spaceId != null) 'spaceId': spaceId,
'name': name,
'parentId': parentId.toJson(),
if (parent != null) 'parent': parent?.toJsonForProtocol(),
};
}
static RequiredSetNullChildInclude include({
_iensfz4m.PersonInclude? parent,
}) {
return RequiredSetNullChildInclude._(parent: parent);
}
static RequiredSetNullChildIncludeList includeList({
_is.WhereExpressionBuilder<RequiredSetNullChildTable>? where,
int? limit,
int? offset,
_is.OrderByBuilder<RequiredSetNullChildTable>? orderBy,
_is.OrderByListBuilder<RequiredSetNullChildTable>? orderByList,
RequiredSetNullChildInclude? include,
}) {
return RequiredSetNullChildIncludeList._(
where: where,
limit: limit,
offset: offset,
orderBy: orderBy?.call(RequiredSetNullChild.t),
orderByList: orderByList?.call(RequiredSetNullChild.t),
include: include,
);
}
@override
String toString() {
return _is.SerializationManager.encode(this);
}
}
class _Undefined {}
class _RequiredSetNullChildImpl extends RequiredSetNullChild {
_RequiredSetNullChildImpl({
_is.UuidValue? id,
int? spaceId,
required String name,
required _is.UuidValue parentId,
_iensfz4m.Person? parent,
}) : super._(
id: id,
spaceId: spaceId,
name: name,
parentId: parentId,
parent: parent,
);
/// Returns a shallow copy of this [RequiredSetNullChild]
/// with some or all fields replaced by the given arguments.
@_is.useResult
@override
RequiredSetNullChild copyWith({
Object? id = _Undefined,
Object? spaceId = _Undefined,
String? name,
_is.UuidValue? parentId,
Object? parent = _Undefined,
}) {
return RequiredSetNullChild(
id: id is _is.UuidValue? ? id : this.id,
spaceId: spaceId is int? ? spaceId : this.spaceId,
name: name ?? this.name,
parentId: parentId ?? this.parentId,
parent: parent is _iensfz4m.Person? ? parent : this.parent?.copyWith(),
);
}
}
class RequiredSetNullChildUpdateTable
extends _is.UpdateTable<RequiredSetNullChildTable> {
RequiredSetNullChildUpdateTable(super.table);
_is.ColumnValue<int, int> spaceId(int? value) => _is.ColumnValue(
table.spaceId,
value,
);
_is.ColumnValue<String, String> name(String value) => _is.ColumnValue(
table.name,
value,
);
_is.ColumnValue<_is.UuidValue, _is.UuidValue> parentId(_is.UuidValue value) =>
_is.ColumnValue(
table.parentId,
value,
);
}
class RequiredSetNullChildTable extends _is.Table<_is.UuidValue?> {
RequiredSetNullChildTable({super.tableRelation})
: super(tableName: 'required_set_null_child') {
updateTable = RequiredSetNullChildUpdateTable(this);
spaceId = _is.ColumnInt(
'spaceId',
this,
);
name = _is.ColumnString(
'name',
this,
);
parentId = _is.ColumnUuid(
'parentId',
this,
);
}
late final RequiredSetNullChildUpdateTable updateTable;
/// The space owning this row. Maintained by the sync engine.
late final _is.ColumnInt spaceId;
late final _is.ColumnString name;
late final _is.ColumnUuid parentId;
_iensfz4m.PersonTable? _parent;
_iensfz4m.PersonTable get parent {
if (_parent != null) return _parent!;
_parent = _is.createRelationTable(
relationFieldName: 'parent',
field: RequiredSetNullChild.t.parentId,
foreignField: _iensfz4m.Person.t.id,
tableRelation: tableRelation,
createTable: (foreignTableRelation) =>
_iensfz4m.PersonTable(tableRelation: foreignTableRelation),
);
return _parent!;
}
@override
List<_is.Column> get columns => [
id,
spaceId,
name,
parentId,
];
@override
_is.Table? getRelationTable(String relationField) {
if (relationField == 'parent') {
return parent;
}
return null;
}
}
class RequiredSetNullChildInclude extends _is.IncludeObject {
RequiredSetNullChildInclude._({_iensfz4m.PersonInclude? parent}) {
_parent = parent;
}
_iensfz4m.PersonInclude? _parent;
@override
Map<String, _is.Include?> get includes => {'parent': _parent};
@override
_is.Table<_is.UuidValue?> get table => RequiredSetNullChild.t;
}
class RequiredSetNullChildIncludeList extends _is.IncludeList {
RequiredSetNullChildIncludeList._({
_is.WhereExpressionBuilder<RequiredSetNullChildTable>? where,
super.limit,
super.offset,
super.orderBy,
super.orderByList,
super.include,
}) {
super.where = where?.call(RequiredSetNullChild.t);
}
@override
Map<String, _is.Include?> get includes => include?.includes ?? {};
@override
_is.Table<_is.UuidValue?> get table => RequiredSetNullChild.t;
}
class RequiredSetNullChildRepository {
const RequiredSetNullChildRepository._();
final attachRow = const RequiredSetNullChildAttachRowRepository._();
/// Returns a list of [RequiredSetNullChild]s matching the given query parameters.
///
/// Use [where] to specify which items to include in the return value.
/// If none is specified, all items will be returned.
///
/// To specify the order of the items use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// The maximum number of items can be set by [limit]. If no limit is set,
/// all items matching the query will be returned.
///
/// [offset] defines how many items to skip, after which [limit] (or all)
/// items are read from the database.
///
/// ```dart
/// var persons = await Persons.db.find(
/// session,
/// where: (t) => t.lastName.equals('Jones'),
/// orderBy: (t) => t.firstName,
/// limit: 100,
/// );
/// ```
Future<List<RequiredSetNullChild>> find(
_is.DatabaseSession session, {
_is.WhereExpressionBuilder<RequiredSetNullChildTable>? where,
int? limit,
int? offset,
_is.OrderByBuilder<RequiredSetNullChildTable>? orderBy,
_is.OrderByListBuilder<RequiredSetNullChildTable>? orderByList,
_is.Transaction? transaction,
RequiredSetNullChildInclude? include,
_is.LockMode? lockMode,
_is.LockBehavior? lockBehavior,
}) async {
return session.db.find<RequiredSetNullChild>(
where: where?.call(RequiredSetNullChild.t),
orderBy: orderBy?.call(RequiredSetNullChild.t),
orderByList: orderByList?.call(RequiredSetNullChild.t),
limit: limit,
offset: offset,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Returns the first matching [RequiredSetNullChild] matching the given query parameters.
///
/// Use [where] to specify which items to include in the return value.
/// If none is specified, all items will be returned.
///
/// To specify the order use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// [offset] defines how many items to skip, after which the next one will be picked.
///
/// ```dart
/// var youngestPerson = await Persons.db.findFirstRow(
/// session,
/// where: (t) => t.lastName.equals('Jones'),
/// orderBy: (t) => t.age,
/// );
/// ```
Future<RequiredSetNullChild?> findFirstRow(
_is.DatabaseSession session, {
_is.WhereExpressionBuilder<RequiredSetNullChildTable>? where,
int? offset,
_is.OrderByBuilder<RequiredSetNullChildTable>? orderBy,
_is.OrderByListBuilder<RequiredSetNullChildTable>? orderByList,
_is.Transaction? transaction,
RequiredSetNullChildInclude? include,
_is.LockMode? lockMode,
_is.LockBehavior? lockBehavior,
}) async {
return session.db.findFirstRow<RequiredSetNullChild>(
where: where?.call(RequiredSetNullChild.t),
orderBy: orderBy?.call(RequiredSetNullChild.t),
orderByList: orderByList?.call(RequiredSetNullChild.t),
offset: offset,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Finds a single [RequiredSetNullChild] by its [id] or null if no such row exists.
Future<RequiredSetNullChild?> findById(
_is.DatabaseSession session,
_is.UuidValue id, {
_is.Transaction? transaction,
RequiredSetNullChildInclude? include,
_is.LockMode? lockMode,
_is.LockBehavior? lockBehavior,
}) async {
return session.db.findById<RequiredSetNullChild>(
id,
transaction: transaction,
include: include,
lockMode: lockMode,
lockBehavior: lockBehavior,
);
}
/// Inserts all [RequiredSetNullChild]s in the list and returns the inserted rows.
///
/// The returned [RequiredSetNullChild]s will have their `id` fields set.
///
/// This is an atomic operation, meaning that if one of the rows fails to
/// insert, none of the rows will be inserted.
///
/// If [ignoreConflicts] is set to `true`, rows that conflict with existing
/// rows are silently skipped, and only the successfully inserted rows are
/// returned.
///
/// If [noReturn] is set to `true`, the inserted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<RequiredSetNullChild>> insert(
_is.DatabaseSession session,
List<RequiredSetNullChild> rows, {
_is.Transaction? transaction,
bool ignoreConflicts = false,
bool noReturn = false,
}) async {
return session.db.insert<RequiredSetNullChild>(
rows,
transaction: transaction,
ignoreConflicts: ignoreConflicts,
noReturn: noReturn,
);
}
/// Inserts a single [RequiredSetNullChild] and returns the inserted row.
///
/// The returned [RequiredSetNullChild] will have its `id` field set.
Future<RequiredSetNullChild> insertRow(
_is.DatabaseSession session,
RequiredSetNullChild row, {
_is.Transaction? transaction,
}) async {
return session.db.insertRow<RequiredSetNullChild>(
row,
transaction: transaction,
);
}
/// Upserts all [RequiredSetNullChild]s in the list and returns the resulting rows.
///
/// If a row conflicts on the given [conflictColumns], the existing row is
/// updated with the new values. Otherwise, a new row is inserted.
///
/// If [updateColumns] is provided, only those columns will be updated on
/// conflict. If null, all non-conflict, non-id columns are updated.
///
/// If [updateWhere] is provided, the update only applies to rows matching the
/// given expression. Conflicting rows that don't match are skipped and not
/// returned, so the resulting list may be shorter than [rows].
///
/// The returned [RequiredSetNullChild]s will have their `id` fields set.
///
/// This is an atomic operation, meaning that if one of the rows fails,
/// none of the rows will be affected.
///
/// If [noReturn] is set to `true`, the resulting rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<RequiredSetNullChild>> upsert(
_is.DatabaseSession session,
List<RequiredSetNullChild> rows, {
required _is.ColumnSelections<RequiredSetNullChildTable> conflictColumns,
_is.ColumnSelections<RequiredSetNullChildTable>? updateColumns,
_is.WhereExpressionBuilder<RequiredSetNullChildTable>? updateWhere,
_is.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.upsert<RequiredSetNullChild>(
rows,
conflictColumns: conflictColumns(RequiredSetNullChild.t),
updateColumns: updateColumns?.call(RequiredSetNullChild.t),
updateWhere: updateWhere?.call(RequiredSetNullChild.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Upserts a single [RequiredSetNullChild] and returns the resulting row.
///
/// If the row conflicts on the given [conflictColumns], the existing row is
/// updated. Otherwise, a new row is inserted.
///
/// If [updateColumns] is provided, only those columns will be updated on
/// conflict. If null, all non-conflict, non-id columns are updated.
///
/// If [updateWhere] is provided, the update only applies when the existing
/// row matches the expression. Returns `null` if no row was affected — for
/// example when [updateWhere] does not match the conflicting row.
///
/// The returned [RequiredSetNullChild] will have its `id` field set.
Future<RequiredSetNullChild?> upsertRow(
_is.DatabaseSession session,
RequiredSetNullChild row, {
required _is.ColumnSelections<RequiredSetNullChildTable> conflictColumns,
_is.ColumnSelections<RequiredSetNullChildTable>? updateColumns,
_is.WhereExpressionBuilder<RequiredSetNullChildTable>? updateWhere,
_is.Transaction? transaction,
}) async {
return session.db.upsertRow<RequiredSetNullChild>(
row,
conflictColumns: conflictColumns(RequiredSetNullChild.t),
updateColumns: updateColumns?.call(RequiredSetNullChild.t),
updateWhere: updateWhere?.call(RequiredSetNullChild.t),
transaction: transaction,
);
}
/// Updates all [RequiredSetNullChild]s in the list and returns the updated rows. If
/// [columns] is provided, only those columns will be updated. Defaults to
/// all columns.
/// This is an atomic operation, meaning that if one of the rows fails to
/// update, none of the rows will be updated.
///
/// If [noReturn] is set to `true`, the updated rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<RequiredSetNullChild>> update(
_is.DatabaseSession session,
List<RequiredSetNullChild> rows, {
_is.ColumnSelections<RequiredSetNullChildTable>? columns,
_is.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.update<RequiredSetNullChild>(
rows,
columns: columns?.call(RequiredSetNullChild.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Updates a single [RequiredSetNullChild]. The row needs to have its id set.
/// Optionally, a list of [columns] can be provided to only update those
/// columns. Defaults to all columns.
Future<RequiredSetNullChild> updateRow(
_is.DatabaseSession session,
RequiredSetNullChild row, {
_is.ColumnSelections<RequiredSetNullChildTable>? columns,
_is.Transaction? transaction,
}) async {
return session.db.updateRow<RequiredSetNullChild>(
row,
columns: columns?.call(RequiredSetNullChild.t),
transaction: transaction,
);
}
/// Updates a single [RequiredSetNullChild] by its [id] with the specified [columnValues].
/// Returns the updated row or null if no row with the given id exists.
Future<RequiredSetNullChild?> updateById(
_is.DatabaseSession session,
_is.UuidValue id, {
required _is.ColumnValueListBuilder<RequiredSetNullChildUpdateTable>
columnValues,
_is.Transaction? transaction,
}) async {
return session.db.updateById<RequiredSetNullChild>(
id,
columnValues: columnValues(RequiredSetNullChild.t.updateTable),
transaction: transaction,
);
}
/// Updates all [RequiredSetNullChild]s matching the [where] expression with the specified [columnValues].
/// Returns the list of updated rows.
///
/// If [noReturn] is set to `true`, the updated rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<RequiredSetNullChild>> updateWhere(
_is.DatabaseSession session, {
required _is.ColumnValueListBuilder<RequiredSetNullChildUpdateTable>
columnValues,
required _is.WhereExpressionBuilder<RequiredSetNullChildTable> where,
int? limit,
int? offset,
_is.OrderByBuilder<RequiredSetNullChildTable>? orderBy,
_is.OrderByListBuilder<RequiredSetNullChildTable>? orderByList,
_is.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.updateWhere<RequiredSetNullChild>(
columnValues: columnValues(RequiredSetNullChild.t.updateTable),
where: where(RequiredSetNullChild.t),
limit: limit,
offset: offset,
orderBy: orderBy?.call(RequiredSetNullChild.t),
orderByList: orderByList?.call(RequiredSetNullChild.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Deletes all [RequiredSetNullChild]s in the list and returns the deleted rows.
///
/// To specify the order of the returned rows use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// This is an atomic operation, meaning that if one of the rows fail to
/// be deleted, none of the rows will be deleted.
///
/// If [noReturn] is set to `true`, the deleted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<RequiredSetNullChild>> delete(
_is.DatabaseSession session,
List<RequiredSetNullChild> rows, {
_is.OrderByBuilder<RequiredSetNullChildTable>? orderBy,
_is.OrderByListBuilder<RequiredSetNullChildTable>? orderByList,
_is.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.delete<RequiredSetNullChild>(
rows,
orderBy: orderBy?.call(RequiredSetNullChild.t),
orderByList: orderByList?.call(RequiredSetNullChild.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Deletes a single [RequiredSetNullChild].
Future<RequiredSetNullChild> deleteRow(
_is.DatabaseSession session,
RequiredSetNullChild row, {
_is.Transaction? transaction,
}) async {
return session.db.deleteRow<RequiredSetNullChild>(
row,
transaction: transaction,
);
}
/// Deletes all rows matching the [where] expression.
///
/// To specify the order of the returned rows use [orderBy] or [orderByList]
/// when sorting by multiple columns.
///
/// If [noReturn] is set to `true`, the deleted rows are not read back from
/// the database and an empty list is returned. This avoids the overhead of
/// transferring and deserializing the rows when the result is not needed.
Future<List<RequiredSetNullChild>> deleteWhere(
_is.DatabaseSession session, {
required _is.WhereExpressionBuilder<RequiredSetNullChildTable> where,
_is.OrderByBuilder<RequiredSetNullChildTable>? orderBy,
_is.OrderByListBuilder<RequiredSetNullChildTable>? orderByList,
_is.Transaction? transaction,
bool noReturn = false,
}) async {
return session.db.deleteWhere<RequiredSetNullChild>(
where: where(RequiredSetNullChild.t),
orderBy: orderBy?.call(RequiredSetNullChild.t),
orderByList: orderByList?.call(RequiredSetNullChild.t),
transaction: transaction,
noReturn: noReturn,
);
}
/// Counts the number of rows matching the [where] expression. If omitted,
/// will return the count of all rows in the table.
Future<int> count(
_is.DatabaseSession session, {
_is.WhereExpressionBuilder<RequiredSetNullChildTable>? where,
int? limit,
_is.Transaction? transaction,
}) async {
return session.db.count<RequiredSetNullChild>(
where: where?.call(RequiredSetNullChild.t),
limit: limit,
transaction: transaction,
);
}
/// Acquires row-level locks on [RequiredSetNullChild] rows matching the [where] expression.
Future<void> lockRows(
_is.DatabaseSession session, {
required _is.WhereExpressionBuilder<RequiredSetNullChildTable> where,
required _is.LockMode lockMode,
required _is.Transaction transaction,
_is.LockBehavior lockBehavior = _is.LockBehavior.wait,
}) async {
return session.db.lockRows<RequiredSetNullChild>(
where: where(RequiredSetNullChild.t),
lockMode: lockMode,
lockBehavior: lockBehavior,
transaction: transaction,
);
}
}
class RequiredSetNullChildAttachRowRepository {
const RequiredSetNullChildAttachRowRepository._();
/// Creates a relation between the given [RequiredSetNullChild] and [Person]
/// by setting the [RequiredSetNullChild]'s foreign key `parentId` to refer to the [Person].
Future<void> parent(
_is.DatabaseSession session,
RequiredSetNullChild requiredSetNullChild,
_iensfz4m.Person parent, {
_is.Transaction? transaction,
}) async {
if (requiredSetNullChild.id == null) {
throw ArgumentError.notNull('requiredSetNullChild.id');
}
if (parent.id == null) {
throw ArgumentError.notNull('parent.id');
}
var $requiredSetNullChild = requiredSetNullChild.copyWith(
parentId: parent.id,
);
await session.db.updateRow<RequiredSetNullChild>(
$requiredSetNullChild,
columns: [RequiredSetNullChild.t.parentId],
transaction: transaction,
);
}
}

View file

@ -25,12 +25,10 @@ import 'fk_chain/set_null_cascade_child.dart' as _ideurard;
import 'fk_chain/set_null_middle.dart' as _icv70ksq;
import 'fk_chain/set_null_restrict_child.dart' as _ix62gjf0;
import 'fk_chain/set_null_set_null_child.dart' as _ihkyqxiw;
import 'nullable_set_default_child.dart' as _i6rvg9xd;
import 'organization.dart' as _irjtvpke;
import 'person.dart' as _iensfz4m;
import 'required_cascade_child.dart' as _ivx9jyda;
import 'required_no_action_child.dart' as _itlfbi2f;
import 'required_set_null_child.dart' as _i1huw131;
import 'restrict_child.dart' as _isrf0aof;
import 'town.dart' as _iytblq2r;
import 'types.dart' as _iwxwszsz;
@ -63,12 +61,10 @@ final List<_is.Table> syncTables = [
_icv70ksq.FkChainSetNullMiddle.t,
_ix62gjf0.FkChainSetNullRestrictChild.t,
_ihkyqxiw.FkChainSetNullSetNullChild.t,
_i6rvg9xd.NullableSetDefaultChild.t,
_irjtvpke.Organization.t,
_iensfz4m.Person.t,
_ivx9jyda.RequiredCascadeChild.t,
_itlfbi2f.RequiredNoActionChild.t,
_i1huw131.RequiredSetNullChild.t,
_isrf0aof.RestrictChild.t,
_i2ap9bqs.SharedChild.t,
_i2ap9bqs.SharedParent.t,

View file

@ -1,6 +0,0 @@
class: NullableSetDefaultChild
table: nullable_set_default_child
database: sync
fields:
name: String
parent: Person?, relation(fk, optional, onDelete=SetDefault, deferred)

View file

@ -1,6 +0,0 @@
class: RequiredSetNullChild
table: required_set_null_child
database: sync
fields:
name: String
parent: Person?, relation(fk, onDelete=SetNull, deferred)