Add docs and changelog entries

This commit is contained in:
Simon Binder 2023-09-14 18:28:55 +02:00
parent 1958dd5cae
commit d0b176e290
4 changed files with 30 additions and 3 deletions

View File

@ -1,6 +1,8 @@
## 2.12.0-dev ## 2.12.0-dev
- Add support for table-valued functions in the Dart query builder. - Add support for table-valued functions in the Dart query builder.
- Add the `@TableIndex` annotation for table classes to add an index to the
table.
- Support `json_each` and `json_tree`. - Support `json_each` and `json_tree`.
## 2.11.1 ## 2.11.1

View File

@ -238,9 +238,24 @@ abstract class View extends HasResultSet {
Query as(); Query as();
} }
/// Annotations for Dart table classes to define a [SQL index](https://sqlite.org/lang_createindex.html)
/// to add to the table.
///
/// ```dart
/// @TableIndex(name: 'item_title', columns: {#title})
/// class TodoItems extends Table {
/// IntColumn get id => integer().autoIncrement()();
/// TextColumn get title => text()();
/// TextColumn get content => text().nullable()();
/// }
/// ```
@Target({TargetKind.classType}) @Target({TargetKind.classType})
final class TableIndex { final class TableIndex {
/// The name of the index in SQL. /// The name of the index in SQL.
///
/// Please note that the name of every table, view, index and other elements
/// in a database must be unique. For this reason, the names of indices are
/// commonly prefixed with the name of the table they're referencing.
final String name; final String name;
/// Whether this index is `UNIQUE`, meaning that the database will forbid /// Whether this index is `UNIQUE`, meaning that the database will forbid
@ -248,8 +263,18 @@ final class TableIndex {
/// indexed columns. /// indexed columns.
final bool unique; final bool unique;
/// The columns of the table that should be part of the index.
///
/// Columns are referenced with a [Symbol] of their getter name used in the
/// column definition. For instance, a table declaring a column as
/// `IntColumn get nextUpdateSnapshot => ...()` could reference this column
/// using `#nextUpdateSnapshot`.
final Set<Symbol> columns; final Set<Symbol> columns;
/// An annotation for Dart-defined drift tables telling drift to add an SQL
/// index to the table.
///
/// See the class documentation at [TableIndex] for an example.
const TableIndex({ const TableIndex({
required this.name, required this.name,
required this.columns, required this.columns,

View File

@ -1,6 +1,6 @@
name: drift name: drift
description: Drift is a reactive library to store relational data in Dart and Flutter applications. description: Drift is a reactive library to store relational data in Dart and Flutter applications.
version: 2.11.1 version: 2.12.0-dev
repository: https://github.com/simolus3/drift repository: https://github.com/simolus3/drift
homepage: https://drift.simonbinder.eu/ homepage: https://drift.simonbinder.eu/
issue_tracker: https://github.com/simolus3/drift/issues issue_tracker: https://github.com/simolus3/drift/issues

View File

@ -1,6 +1,6 @@
name: drift_dev name: drift_dev
description: Dev-dependency for users of drift. Contains the generator and development tools. description: Dev-dependency for users of drift. Contains the generator and development tools.
version: 2.11.2 version: 2.12.0-dev
repository: https://github.com/simolus3/drift repository: https://github.com/simolus3/drift
homepage: https://drift.simonbinder.eu/ homepage: https://drift.simonbinder.eu/
issue_tracker: https://github.com/simolus3/drift/issues issue_tracker: https://github.com/simolus3/drift/issues
@ -30,7 +30,7 @@ dependencies:
io: ^1.0.3 io: ^1.0.3
# Drift-specific analysis and apis # Drift-specific analysis and apis
drift: '>=2.11.0 <2.12.0' drift: '>=2.12.0 <2.13.0'
sqlite3: '>=0.1.6 <3.0.0' sqlite3: '>=0.1.6 <3.0.0'
sqlparser: '^0.31.0' sqlparser: '^0.31.0'