Skip to content

Drift 2.0.0

Compare
Choose a tag to compare
@simolus3 simolus3 released this 14 Aug 15:56
· 1577 commits to develop since this release
d9f342a

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 and fromSql.
  • Breaking: Removed SqlTypeSystem and subtypes of SqlType:
    • 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 via database.options.types.
  • Breaking: Expressions (including Columns) always have a non-nullable type parameter now. They are implicitly nullable, so TypedResult.read now returns a nullable value.
  • Breaking: QueryRow.read can only read non-nullable values now. To read nullable values, use readNullable.
  • Breaking: Remove the includeJoinedTableColumns parameter on selectOnly(). The method now behaves as if that parameter was turned off. To use columns from a joined table, add them with addColumns.
  • Breaking: Remove the fromData factory on generated data classes. Use the map 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 or COMMIT across database implementations.
  • Add writeReturning to update statements; deleteReturning and goAndReturn 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.