From 6184892217902461743fd72108a8a4635e6f2605 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Fri, 18 Feb 2022 15:09:51 +0100 Subject: [PATCH] Add more docs, changelog --- drift/CHANGELOG.md | 5 +++++ drift/lib/src/dsl/table.dart | 32 +++++++++++++++++++++++++++++++- drift/pubspec.yaml | 2 +- drift_dev/pubspec.yaml | 4 ++-- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/drift/CHANGELOG.md b/drift/CHANGELOG.md index 61e4a3a0..9fb14546 100644 --- a/drift/CHANGELOG.md +++ b/drift/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.5.0-dev + +- Add `DataClassName.extending` to control the superclass of generated row + classes. + ## 1.4.0 - Most methods to compose statements are now available as an extension on diff --git a/drift/lib/src/dsl/table.dart b/drift/lib/src/dsl/table.dart index d3e7097c..e00e000a 100644 --- a/drift/lib/src/dsl/table.dart +++ b/drift/lib/src/dsl/table.dart @@ -184,7 +184,37 @@ class DataClassName { /// {@macro drift_custom_data_class} final String name; - /// The parent class of generated data class. Class must extends [DataClass]! + /// The parent type of the data class generated by drift. + /// + /// The [extending] type must refer to an interface type (usually just a + /// class name), and the parent class must extend [DataClass]. + /// + /// The extended class can optionally have a type parameter, which is + /// instantiated to the actual data class generated by drift. + /// + /// For example, + /// + /// ```dart + /// abstract class BaseModel extends DataClass { + /// abstract final String id; + /// } + /// + /// abstract class TypedBaseModel extends DataClass { + /// + /// } + /// + /// @DataClassName('Company', extending: BaseModel) + /// class Companies extends Table { + /// TextColumn get id => text()(); + /// TextColumn get name => text().named('name')(); + /// } + /// + /// // The actual generated class will extend `TypedBaseModel`. + /// @DataClassName('Employee', extending: TypedBaseModel) + /// class Employees extends Table { + /// TextColumn get id => text()(); + /// } + /// ``` final Type? extending; /// Customize the data class name for a given table. diff --git a/drift/pubspec.yaml b/drift/pubspec.yaml index ffe60ae4..f136a7f6 100644 --- a/drift/pubspec.yaml +++ b/drift/pubspec.yaml @@ -1,6 +1,6 @@ name: drift description: Drift is a reactive library to store relational data in Dart and Flutter applications. -version: 1.4.0 +version: 1.5.0-dev repository: https://github.com/simolus3/moor homepage: https://drift.simonbinder.eu/ issue_tracker: https://github.com/simolus3/moor/issues diff --git a/drift_dev/pubspec.yaml b/drift_dev/pubspec.yaml index 1ed59f32..546922d4 100644 --- a/drift_dev/pubspec.yaml +++ b/drift_dev/pubspec.yaml @@ -1,6 +1,6 @@ name: drift_dev description: Dev-dependency for users of drift. Contains a the generator and development tools. -version: 1.4.0 +version: 1.5.0-dev repository: https://github.com/simolus3/moor homepage: https://drift.simonbinder.eu/ issue_tracker: https://github.com/simolus3/moor/issues @@ -25,7 +25,7 @@ dependencies: io: ^1.0.3 # Drift-specific analysis and apis - drift: '>=1.4.0 <1.5.0' + drift: '>=1.5.0 <1.6.0' sqlite3: '>=0.1.6 <2.0.0' sqlparser: ^0.20.0