Re-run builders, add changelog entry

This commit is contained in:
Simon Binder 2023-11-22 13:09:09 +01:00
parent 3fb9e50f75
commit 28c3c444e7
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
7 changed files with 55 additions and 50 deletions

View File

@ -1,5 +1,10 @@
## 2.14.0-dev
- __Breaking change__: The name of the generated row class derived from the name
of the Dart table name now supports more forms of plurals.
For instance, a table without a `@DataClassName` annotation named `Categories`
would now generate a `Category` class instead of `Categorie`.
## 2.13.2
- Fix generated queries relying on custom types.

View File

@ -14,19 +14,19 @@ String dataClassNameForClassName(String tableName) {
// from the table name.
if (tableName.endsWith('s')) {
if (tableName.endsWith('ss') || tableName.endsWith('us') || tableName.endsWith('sses')) {
if (tableName.endsWith('ss') ||
tableName.endsWith('us') ||
tableName.endsWith('sses')) {
return tableName;
} else if (tableName.endsWith('ies')) {
return tableName.substring(0, tableName.length - 3) + 'y';
return '${tableName.substring(0, tableName.length - 3)}y';
} else {
return tableName.substring(0, tableName.length - 1);
}
} else {
return tableName;
// Default behavior if the table name is not a valid plural.
return '${tableName}Data';
}
// Default behavior if the table name is not a valid plural.
return '${tableName}Data';
}
AnnotatedDartCode? parseCustomParentClass(

View File

@ -473,8 +473,8 @@ class TodoEntriesCompanion extends UpdateCompanion<TodoEntry> {
class TextEntries extends Table
with
TableInfo<TextEntries, TextEntrie>,
VirtualTableInfo<TextEntries, TextEntrie> {
TableInfo<TextEntries, TextEntry>,
VirtualTableInfo<TextEntries, TextEntry> {
@override
final GeneratedDatabase attachedDatabase;
final String? _alias;
@ -494,7 +494,7 @@ class TextEntries extends Table
String get actualTableName => $name;
static const String $name = 'text_entries';
@override
VerificationContext validateIntegrity(Insertable<TextEntrie> instance,
VerificationContext validateIntegrity(Insertable<TextEntry> instance,
{bool isInserting = false}) {
final context = VerificationContext();
final data = instance.toColumns(true);
@ -512,9 +512,9 @@ class TextEntries extends Table
@override
Set<GeneratedColumn> get $primaryKey => const {};
@override
TextEntrie map(Map<String, dynamic> data, {String? tablePrefix}) {
TextEntry map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return TextEntrie(
return TextEntry(
description: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}description'])!,
);
@ -532,9 +532,9 @@ class TextEntries extends Table
'fts5(description, content=todo_entries, content_rowid=id)';
}
class TextEntrie extends DataClass implements Insertable<TextEntrie> {
class TextEntry extends DataClass implements Insertable<TextEntry> {
final String description;
const TextEntrie({required this.description});
const TextEntry({required this.description});
@override
Map<String, Expression> toColumns(bool nullToAbsent) {
final map = <String, Expression>{};
@ -548,10 +548,10 @@ class TextEntrie extends DataClass implements Insertable<TextEntrie> {
);
}
factory TextEntrie.fromJson(Map<String, dynamic> json,
factory TextEntry.fromJson(Map<String, dynamic> json,
{ValueSerializer? serializer}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return TextEntrie(
return TextEntry(
description: serializer.fromJson<String>(json['description']),
);
}
@ -563,12 +563,12 @@ class TextEntrie extends DataClass implements Insertable<TextEntrie> {
};
}
TextEntrie copyWith({String? description}) => TextEntrie(
TextEntry copyWith({String? description}) => TextEntry(
description: description ?? this.description,
);
@override
String toString() {
return (StringBuffer('TextEntrie(')
return (StringBuffer('TextEntry(')
..write('description: $description')
..write(')'))
.toString();
@ -579,10 +579,10 @@ class TextEntrie extends DataClass implements Insertable<TextEntrie> {
@override
bool operator ==(Object other) =>
identical(this, other) ||
(other is TextEntrie && other.description == this.description);
(other is TextEntry && other.description == this.description);
}
class TextEntriesCompanion extends UpdateCompanion<TextEntrie> {
class TextEntriesCompanion extends UpdateCompanion<TextEntry> {
final Value<String> description;
final Value<int> rowid;
const TextEntriesCompanion({
@ -593,7 +593,7 @@ class TextEntriesCompanion extends UpdateCompanion<TextEntrie> {
required String description,
this.rowid = const Value.absent(),
}) : description = Value(description);
static Insertable<TextEntrie> custom({
static Insertable<TextEntry> custom({
Expression<String>? description,
Expression<int>? rowid,
}) {

View File

@ -9,7 +9,7 @@ environment:
dependencies:
drift: ^2.0.2+1
sqlcipher_flutter_libs: ^0.5.1
sqlcipher_flutter_libs: ^0.6.0
flutter:
sdk: flutter
path_provider: ^2.0.11

View File

@ -14,7 +14,7 @@ void main() {
}
class _DatabaseSampleState extends State<_DatabaseSample> {
List<Entrie> allItems = [];
List<Entry> allItems = [];
TextEditingController editController = TextEditingController();
final database = MyDatabase(Platform.createDatabaseConnection('sample'));

View File

@ -3,7 +3,7 @@
part of 'database.dart';
// ignore_for_file: type=lint
class Entries extends Table with TableInfo<Entries, Entrie> {
class Entries extends Table with TableInfo<Entries, Entry> {
@override
final GeneratedDatabase attachedDatabase;
final String? _alias;
@ -28,7 +28,7 @@ class Entries extends Table with TableInfo<Entries, Entrie> {
String get actualTableName => $name;
static const String $name = 'entries';
@override
VerificationContext validateIntegrity(Insertable<Entrie> instance,
VerificationContext validateIntegrity(Insertable<Entry> instance,
{bool isInserting = false}) {
final context = VerificationContext();
final data = instance.toColumns(true);
@ -47,9 +47,9 @@ class Entries extends Table with TableInfo<Entries, Entrie> {
@override
Set<GeneratedColumn> get $primaryKey => {id};
@override
Entrie map(Map<String, dynamic> data, {String? tablePrefix}) {
Entry map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return Entrie(
return Entry(
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
value: attachedDatabase.typeMapping
@ -66,10 +66,10 @@ class Entries extends Table with TableInfo<Entries, Entrie> {
bool get dontWriteConstraints => true;
}
class Entrie extends DataClass implements Insertable<Entrie> {
class Entry extends DataClass implements Insertable<Entry> {
final int id;
final String value;
const Entrie({required this.id, required this.value});
const Entry({required this.id, required this.value});
@override
Map<String, Expression> toColumns(bool nullToAbsent) {
final map = <String, Expression>{};
@ -85,10 +85,10 @@ class Entrie extends DataClass implements Insertable<Entrie> {
);
}
factory Entrie.fromJson(Map<String, dynamic> json,
factory Entry.fromJson(Map<String, dynamic> json,
{ValueSerializer? serializer}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return Entrie(
return Entry(
id: serializer.fromJson<int>(json['id']),
value: serializer.fromJson<String>(json['text']),
);
@ -102,13 +102,13 @@ class Entrie extends DataClass implements Insertable<Entrie> {
};
}
Entrie copyWith({int? id, String? value}) => Entrie(
Entry copyWith({int? id, String? value}) => Entry(
id: id ?? this.id,
value: value ?? this.value,
);
@override
String toString() {
return (StringBuffer('Entrie(')
return (StringBuffer('Entry(')
..write('id: $id, ')
..write('value: $value')
..write(')'))
@ -120,10 +120,10 @@ class Entrie extends DataClass implements Insertable<Entrie> {
@override
bool operator ==(Object other) =>
identical(this, other) ||
(other is Entrie && other.id == this.id && other.value == this.value);
(other is Entry && other.id == this.id && other.value == this.value);
}
class EntriesCompanion extends UpdateCompanion<Entrie> {
class EntriesCompanion extends UpdateCompanion<Entry> {
final Value<int> id;
final Value<String> value;
const EntriesCompanion({
@ -134,7 +134,7 @@ class EntriesCompanion extends UpdateCompanion<Entrie> {
this.id = const Value.absent(),
required String value,
}) : value = Value(value);
static Insertable<Entrie> custom({
static Insertable<Entry> custom({
Expression<int>? id,
Expression<String>? value,
}) {
@ -176,7 +176,7 @@ class EntriesCompanion extends UpdateCompanion<Entrie> {
abstract class _$MyDatabase extends GeneratedDatabase {
_$MyDatabase(QueryExecutor e) : super(e);
late final Entries entries = Entries(this);
Selectable<Entrie> allEntries() {
Selectable<Entry> allEntries() {
return customSelect('SELECT * FROM entries', variables: [], readsFrom: {
entries,
}).asyncMap(entries.mapFromRow);

View File

@ -3,7 +3,7 @@
part of 'database.dart';
// ignore_for_file: type=lint
class Entries extends Table with TableInfo<Entries, Entrie> {
class Entries extends Table with TableInfo<Entries, Entry> {
@override
final GeneratedDatabase attachedDatabase;
final String? _alias;
@ -28,7 +28,7 @@ class Entries extends Table with TableInfo<Entries, Entrie> {
String get actualTableName => $name;
static const String $name = 'entries';
@override
VerificationContext validateIntegrity(Insertable<Entrie> instance,
VerificationContext validateIntegrity(Insertable<Entry> instance,
{bool isInserting = false}) {
final context = VerificationContext();
final data = instance.toColumns(true);
@ -47,9 +47,9 @@ class Entries extends Table with TableInfo<Entries, Entrie> {
@override
Set<GeneratedColumn> get $primaryKey => {id};
@override
Entrie map(Map<String, dynamic> data, {String? tablePrefix}) {
Entry map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return Entrie(
return Entry(
id: attachedDatabase.typeMapping
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
value: attachedDatabase.typeMapping
@ -66,10 +66,10 @@ class Entries extends Table with TableInfo<Entries, Entrie> {
bool get dontWriteConstraints => true;
}
class Entrie extends DataClass implements Insertable<Entrie> {
class Entry extends DataClass implements Insertable<Entry> {
final int id;
final String value;
const Entrie({required this.id, required this.value});
const Entry({required this.id, required this.value});
@override
Map<String, Expression> toColumns(bool nullToAbsent) {
final map = <String, Expression>{};
@ -85,10 +85,10 @@ class Entrie extends DataClass implements Insertable<Entrie> {
);
}
factory Entrie.fromJson(Map<String, dynamic> json,
factory Entry.fromJson(Map<String, dynamic> json,
{ValueSerializer? serializer}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return Entrie(
return Entry(
id: serializer.fromJson<int>(json['id']),
value: serializer.fromJson<String>(json['text']),
);
@ -102,13 +102,13 @@ class Entrie extends DataClass implements Insertable<Entrie> {
};
}
Entrie copyWith({int? id, String? value}) => Entrie(
Entry copyWith({int? id, String? value}) => Entry(
id: id ?? this.id,
value: value ?? this.value,
);
@override
String toString() {
return (StringBuffer('Entrie(')
return (StringBuffer('Entry(')
..write('id: $id, ')
..write('value: $value')
..write(')'))
@ -120,10 +120,10 @@ class Entrie extends DataClass implements Insertable<Entrie> {
@override
bool operator ==(Object other) =>
identical(this, other) ||
(other is Entrie && other.id == this.id && other.value == this.value);
(other is Entry && other.id == this.id && other.value == this.value);
}
class EntriesCompanion extends UpdateCompanion<Entrie> {
class EntriesCompanion extends UpdateCompanion<Entry> {
final Value<int> id;
final Value<String> value;
const EntriesCompanion({
@ -134,7 +134,7 @@ class EntriesCompanion extends UpdateCompanion<Entrie> {
this.id = const Value.absent(),
required String value,
}) : value = Value(value);
static Insertable<Entrie> custom({
static Insertable<Entry> custom({
Expression<int>? id,
Expression<String>? value,
}) {
@ -176,7 +176,7 @@ class EntriesCompanion extends UpdateCompanion<Entrie> {
abstract class _$MyDatabase extends GeneratedDatabase {
_$MyDatabase(QueryExecutor e) : super(e);
late final Entries entries = Entries(this);
Selectable<Entrie> allEntries() {
Selectable<Entry> allEntries() {
return customSelect('SELECT * FROM entries', variables: [], readsFrom: {
entries,
}).asyncMap(entries.mapFromRow);