Drift 2.0.0
simolus3
released this
14 Aug 15:56
·
1577 commits
to develop
since this release
The first major update to the drift
packages contains a number of breaking changes and removes some obsolete features. This includes:
- Breaking: Type converters now return the types that they were defined to return (instead of the nullable variant of those types like before). It is an error to use a non-nullable type converter on a column that is nullable in SQL and vice-versa.
- Breaking: Mapping methods on type converters are now called
toSql
andfromSql
. - Breaking: Removed
SqlTypeSystem
and subtypes ofSqlType
:- To describe the type a column has, use the
DriftSqlType
enum - To map a value from Dart to SQL and vice-versa, use an instance of
SqlTypes
, reachable viadatabase.options.types
.
- To describe the type a column has, use the
- Breaking:
Expression
s (includingColumn
s) always have a non-nullable type parameter now. They are implicitly nullable, soTypedResult.read
now returns a nullable value. - Breaking:
QueryRow.read
can only read non-nullable values now. To read nullable values, usereadNullable
. - Breaking: Remove the
includeJoinedTableColumns
parameter onselectOnly()
. The method now behaves as if that parameter was turned off. To use columns from a joined table, add them withaddColumns
. - Breaking: Remove the
fromData
factory on generated data classes. Use themap
method on tables instead. - Add support for storing date times as (ISO-8601) strings. For details on how to use this, see the documentation.
- Consistently handle transaction errors like a failing
BEGIN
orCOMMIT
across database implementations. - Add
writeReturning
to update statements;deleteReturning
andgoAndReturn
to delete statatements. - Support nested transactions.
- Support custom collations in the query builder API.
- Custom row classes can now be constructed with static methods too. These static factories can also be asynchronous.
💡: More information on how to migrate is available in the documentation.