From cd520e5d1e117f3dc2e2e495e9f6c00abe690c27 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Mon, 29 Apr 2019 18:23:39 +0200 Subject: [PATCH] Fix syntax error in generated code with empty primary key --- moor/pubspec.yaml | 2 +- moor/test/data/tables/todos.dart | 2 -- moor/test/data/tables/todos.g.dart | 2 +- moor_generator/lib/src/writer/table_writer.dart | 4 ++-- moor_generator/pubspec.yaml | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/moor/pubspec.yaml b/moor/pubspec.yaml index 4bc57bc9..8f99663b 100644 --- a/moor/pubspec.yaml +++ b/moor/pubspec.yaml @@ -1,6 +1,6 @@ name: moor 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 authors: - Simon Binder diff --git a/moor/test/data/tables/todos.dart b/moor/test/data/tables/todos.dart index 71990bfb..1d85e4db 100644 --- a/moor/test/data/tables/todos.dart +++ b/moor/test/data/tables/todos.dart @@ -47,9 +47,7 @@ class SharedTodos extends Table { } class TableWithoutPK extends Table { - IntColumn get notReallyAnId => integer()(); - } @UseMoor(tables: [TodosTable, Categories, Users, SharedTodos, TableWithoutPK]) diff --git a/moor/test/data/tables/todos.g.dart b/moor/test/data/tables/todos.g.dart index bdd72994..42856cb8 100644 --- a/moor/test/data/tables/todos.g.dart +++ b/moor/test/data/tables/todos.g.dart @@ -716,7 +716,7 @@ class $TableWithoutPKTable extends TableWithoutPK bool validateIntegrity(TableWithoutPKData instance, bool isInserting) => notReallyAnId.isAcceptableValue(instance.notReallyAnId, isInserting); @override - Set get $primaryKey => {}; + Set get $primaryKey => {}; @override TableWithoutPKData map(Map data, {String tablePrefix}) { final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : null; diff --git a/moor_generator/lib/src/writer/table_writer.dart b/moor_generator/lib/src/writer/table_writer.dart index dca7e644..0039a98d 100644 --- a/moor_generator/lib/src/writer/table_writer.dart +++ b/moor_generator/lib/src/writer/table_writer.dart @@ -175,8 +175,8 @@ class TableWriter { // explicitly defined as PK, but with AI this happens implicitly. primaryKey ??= table.columns.where((c) => c.hasAI).toSet(); - if (primaryKey == null) { - buffer.write('null;'); + if (primaryKey.isEmpty) { + buffer.write('{};'); return; } diff --git a/moor_generator/pubspec.yaml b/moor_generator/pubspec.yaml index c725ada0..3f93d120 100644 --- a/moor_generator/pubspec.yaml +++ b/moor_generator/pubspec.yaml @@ -1,6 +1,6 @@ name: moor_generator 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 authors: - Simon Binder