mirror of https://github.com/AMT-Cheif/drift.git
Add changelog entry, expand docs a bit
This commit is contained in:
parent
4e508b62ab
commit
6047ec912f
|
@ -1,5 +1,7 @@
|
||||||
## 1.6.0-dev
|
## 1.6.0-dev
|
||||||
|
|
||||||
|
- Add the `unique()` method to columns and the `uniqueKeys` override to tables
|
||||||
|
to define unique constraints in Dart tables.
|
||||||
- Add the very experimental `package:drift/wasm.dart` library. It uses WebAssembly
|
- Add the very experimental `package:drift/wasm.dart` library. It uses WebAssembly
|
||||||
to access sqlite3 without any external JavaScript libraries, but requires you to
|
to access sqlite3 without any external JavaScript libraries, but requires you to
|
||||||
add a [WebAssembly module](https://github.com/simolus3/sqlite3.dart/tree/main/sqlite3#wasm-web-support)
|
add a [WebAssembly module](https://github.com/simolus3/sqlite3.dart/tree/main/sqlite3#wasm-web-support)
|
||||||
|
|
|
@ -95,8 +95,8 @@ extension BuildColumn<T> on ColumnBuilder<T> {
|
||||||
/// [constraint] if that is desired.
|
/// [constraint] if that is desired.
|
||||||
///
|
///
|
||||||
/// This can be used to implement constraints that drift does not (yet)
|
/// This can be used to implement constraints that drift does not (yet)
|
||||||
/// support (e.g. unique keys, etc.). If you've found a common use-case for
|
/// support. If you've found a common use-case for this, it should be
|
||||||
/// this, it should be considered a limitation of drift itself. Please feel
|
/// considered a limitation of drift itself. Please feel
|
||||||
/// free to open an issue at https://github.com/simolus3/drift/issues/new to
|
/// free to open an issue at https://github.com/simolus3/drift/issues/new to
|
||||||
/// report that.
|
/// report that.
|
||||||
///
|
///
|
||||||
|
@ -253,6 +253,9 @@ extension BuildGeneralColumn<T> on _BaseColumnBuilder<T> {
|
||||||
ColumnBuilder<T?> nullable() => _isGenerated();
|
ColumnBuilder<T?> nullable() => _isGenerated();
|
||||||
|
|
||||||
/// Adds UNIQUE constraint to column.
|
/// Adds UNIQUE constraint to column.
|
||||||
|
///
|
||||||
|
/// Unique constraints spanning multiple keys can be added to a table by
|
||||||
|
/// overriding [Table.uniqueKeys].
|
||||||
ColumnBuilder<T?> unique() => _isGenerated();
|
ColumnBuilder<T?> unique() => _isGenerated();
|
||||||
|
|
||||||
/// Uses a custom [converter] to store custom Dart objects in a single column
|
/// Uses a custom [converter] to store custom Dart objects in a single column
|
||||||
|
|
|
@ -62,7 +62,13 @@ abstract class Table extends HasResultSet {
|
||||||
@visibleForOverriding
|
@visibleForOverriding
|
||||||
Set<Column>? get primaryKey => null;
|
Set<Column>? get primaryKey => null;
|
||||||
|
|
||||||
|
/// Unique constraints in this table.
|
||||||
|
///
|
||||||
|
/// When two rows have the same value in _any_ set specified in [uniqueKeys],
|
||||||
|
/// the database will reject the second row for inserts.
|
||||||
|
///
|
||||||
/// Override this to specify unique keys:
|
/// Override this to specify unique keys:
|
||||||
|
///
|
||||||
/// ```dart
|
/// ```dart
|
||||||
/// class IngredientInRecipes extends Table {
|
/// class IngredientInRecipes extends Table {
|
||||||
/// @override
|
/// @override
|
||||||
|
@ -73,10 +79,14 @@ abstract class Table extends HasResultSet {
|
||||||
/// IntColumn get ingredient => integer()();
|
/// IntColumn get ingredient => integer()();
|
||||||
///
|
///
|
||||||
/// IntColumn get amountInGrams => integer().named('amount')();
|
/// IntColumn get amountInGrams => integer().named('amount')();
|
||||||
///}
|
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
/// The getter must return a list of set literals using the `=>` syntax so
|
/// The getter must return a list of set literals using the `=>` syntax so
|
||||||
/// that the drift generator can understand the code.
|
/// that the drift generator can understand the code.
|
||||||
|
///
|
||||||
|
/// Note that individual columns can also be marked as unique with
|
||||||
|
/// [BuildGeneralColumn.unique]. This is equivalent to adding a single-element
|
||||||
|
/// set to this list.
|
||||||
@visibleForOverriding
|
@visibleForOverriding
|
||||||
List<Set<Column>>? get uniqueKeys => null;
|
List<Set<Column>>? get uniqueKeys => null;
|
||||||
|
|
||||||
|
|
|
@ -262,7 +262,8 @@ dependency_overrides:
|
||||||
moor:
|
moor:
|
||||||
path: /foo/bar
|
path: /foo/bar
|
||||||
moor_generator:
|
moor_generator:
|
||||||
hosted: foo
|
hosted:
|
||||||
|
url: foo
|
||||||
version: ^1.2.3
|
version: ^1.2.3
|
||||||
''');
|
''');
|
||||||
|
|
||||||
|
@ -288,7 +289,8 @@ dependency_overrides:
|
||||||
drift:
|
drift:
|
||||||
path: /foo/bar
|
path: /foo/bar
|
||||||
drift_dev:
|
drift_dev:
|
||||||
hosted: foo
|
hosted:
|
||||||
|
url: foo
|
||||||
version: ^1.2.3
|
version: ^1.2.3
|
||||||
'''),
|
'''),
|
||||||
]).validate();
|
]).validate();
|
||||||
|
|
Loading…
Reference in New Issue