Fix syntax error in generated code with empty primary key

This commit is contained in:
Simon Binder 2019-04-29 18:23:39 +02:00
parent 211bf56ae7
commit cd520e5d1e
No known key found for this signature in database
GPG Key ID: B807FDF954BA00CF
5 changed files with 5 additions and 7 deletions

View File

@ -1,6 +1,6 @@
name: moor name: moor
description: Moor is a safe and reactive persistence library for Dart applications description: Moor is a safe and reactive persistence library for Dart applications
version: 1.3.0 version: 1.3.1
homepage: https://github.com/simolus3/moor homepage: https://github.com/simolus3/moor
authors: authors:
- Simon Binder <simolus3@gmail.com> - Simon Binder <simolus3@gmail.com>

View File

@ -47,9 +47,7 @@ class SharedTodos extends Table {
} }
class TableWithoutPK extends Table { class TableWithoutPK extends Table {
IntColumn get notReallyAnId => integer()(); IntColumn get notReallyAnId => integer()();
} }
@UseMoor(tables: [TodosTable, Categories, Users, SharedTodos, TableWithoutPK]) @UseMoor(tables: [TodosTable, Categories, Users, SharedTodos, TableWithoutPK])

View File

@ -716,7 +716,7 @@ class $TableWithoutPKTable extends TableWithoutPK
bool validateIntegrity(TableWithoutPKData instance, bool isInserting) => bool validateIntegrity(TableWithoutPKData instance, bool isInserting) =>
notReallyAnId.isAcceptableValue(instance.notReallyAnId, isInserting); notReallyAnId.isAcceptableValue(instance.notReallyAnId, isInserting);
@override @override
Set<GeneratedColumn> get $primaryKey => {}; Set<GeneratedColumn> get $primaryKey => <GeneratedColumn>{};
@override @override
TableWithoutPKData map(Map<String, dynamic> data, {String tablePrefix}) { TableWithoutPKData map(Map<String, dynamic> data, {String tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null;

View File

@ -175,8 +175,8 @@ class TableWriter {
// explicitly defined as PK, but with AI this happens implicitly. // explicitly defined as PK, but with AI this happens implicitly.
primaryKey ??= table.columns.where((c) => c.hasAI).toSet(); primaryKey ??= table.columns.where((c) => c.hasAI).toSet();
if (primaryKey == null) { if (primaryKey.isEmpty) {
buffer.write('null;'); buffer.write('<GeneratedColumn>{};');
return; return;
} }

View File

@ -1,6 +1,6 @@
name: moor_generator name: moor_generator
description: Dev-dependency to generate table and dataclasses together with the moor package. description: Dev-dependency to generate table and dataclasses together with the moor package.
version: 1.3.0 version: 1.3.1
homepage: https://github.com/simolus3/moor homepage: https://github.com/simolus3/moor
authors: authors:
- Simon Binder <simolus3@gmail.com> - Simon Binder <simolus3@gmail.com>