jao 0.3.0
jao: ^0.3.0 copied to clipboard
A Django-inspired ORM for Dart. Type-safe queries, lazy QuerySets, PostgreSQL/SQLite/MySQL support. Perfect for Dart Frog, Shelf, and dart applications.
[Unreleased] #
0.3.0 - 2026-02-23 #
Added #
-
Multi-model transaction support via
Jao.instance.transaction():- New
JaoTransactionclass that holds a sharedTransactionand vends typedTransactionExecutor<T>instances for any registered model - New
Jao.transaction<R>()method — acquires one connection, wraps it in one atomic transaction, and exposes all registered models viatx.on<T>() - All
tx.on<T>()calls within a singletransaction()block share the same underlying DB connection and commit/roll back together - Existing single-model
executor.transaction()API is unchanged (no breaking change)
- New
-
Savepoint support:
Transactioninterface gainssavepoint(name),rollbackToSavepoint(name), andreleaseSavepoint(name)- Implemented across all three adapters (PostgreSQL, SQLite, MySQL)
JaoTransaction.savepoint()— runs a sub-operation inside a savepoint; if it throws, only that sub-operation is rolled back and the outer transaction remains alive
-
EnumFieldsupport in migration schema generator:fieldDefToDbTypenow handlesEnumFieldannotation- Returns
FieldType.integerwhenstoreAsInt: true - Returns
FieldType.varcharfor string-based storage (default)
-
Auto-detection of nullability changes in
_generateTableDiff:- Compares model field nullability with database column nullability
- Generates
AlterColumnoperations when nullability differs - Skips primary key fields (SQLite reports PK as nullable even when NOT NULL)
-
Auto-detection of type changes in
_generateTableDiff:- Normalizes raw database type strings to
FieldTypefor comparison - Supports SQLite, PostgreSQL, and MySQL type naming conventions
- Generates
AlterColumnoperations when types differ - Skips integer-like type mismatches for PKs (serial vs integer)
- Normalizes raw database type strings to
-
AlterColumnmigration code generation:- Generates
builder.alterColumn()calls with proper modifiers - Supports nullability changes (
col.nullable()/col.notNullable()) - Supports type changes, default values, and column renames
- Generates reverse operations in
down()for nullability changes
- Generates
-
SQLite type equivalence logic in
_generateTableDiff:- Prevents false positive type changes due to SQLite type affinity
- TEXT types (varchar, timestamp, uuid, json) are equivalent in SQLite
- INTEGER types (int, bigint, boolean, serial) are equivalent in SQLite
- REAL types (real, double, decimal) are equivalent in SQLite
- BLOB types (bytea, blob) are equivalent in SQLite
-
SQLite table recreation for
AlterColumnoperations:- Implements Django-style
_remake_tablepattern for SQLite - Automatically renames old table, creates new table with modified schema
- Copies data from old table to new table preserving all rows
- Recreates indexes and foreign key constraints
- Supports nullability changes, type changes, default values, and renames
- Implements Django-style
0.2.5 - 2026-02-09 #
Added #
- Default values support for model fields:
defaultValuesparameter inModelRegistrationandModelExecutor- Automatically applies default values during
create()andbulkCreate()when field is not provided or null - Works with all field types (string, int, bool, double)
0.2.4 - 2026-01-01 #
Added #
- Common Table Expressions (CTE) support:
Cteclass for defining non-recursive CTEsRecursiveCteclass for hierarchical/recursive queriesCteRefandCteColumnReffor referencing CTE columnsCteQueryinterface for queries that can be used in CTEs.with_()method on QuerySet to attach CTEs.fromCte()method on QuerySet to select from a CTE- SQL compiler generates
WITHandWITH RECURSIVEclauses
0.2.3 - 2026-01-01 #
Added #
values()method on QuerySet for selecting specific columns as raw mapsvaluesFlat<V>()method on QuerySet for selecting a single column as a flat listValuesQuerySetandValuesListQuerySetclasses with full query chaining support- New executor methods:
executeValues()andexecuteValuesFlat<V>()
0.2.2 - 2026-01-01 #
Added #
- Model metadata system for proper JOIN compilation:
ModelMetadata,FieldMeta,RelationMetaclasses for runtime metadataModelRegistryfor global model metadata lookups- SQL compiler now uses registry for accurate JOIN clauses
- Falls back to convention-based joins if metadata not registered
0.2.0 - 2025-12-31 #
Added #
- Type converter functions for cross-database compatibility:
dbDateTime,dbDateTimeOrNull- handles DateTime, String, and int (timestamp)dbBool,dbBoolOrNull- handles bool, int (0/1), and StringdbInt,dbIntOrNull- handles int, double, and StringdbDouble,dbDoubleOrNull- handles double, int, and StringdbDuration,dbDurationOrNull- handles Duration, int (microseconds), and String
Fixed #
- Cross-database type compatibility issue where
fromRow()failed with PostgreSQL native types (#4)
0.1.0 - 2025-12-28 #
Added #
DatabaseConfig.postgres()factory constructor for PostgreSQL configurationDatabaseConfig.mysql()factory constructor for MySQL configuration
0.0.1 - 2025-12-28 #
Added #
- Initial release
- Django-style model definitions with field annotations
- Type-safe query building with
Qexpressions - Multi-database support (SQLite, PostgreSQL, MySQL)
- Schema migrations with up/down support
- Auto-generated
created_atandupdated_attimestamps viaautoNowandautoNowAdd - Manager pattern for database operations
- Field types:
AutoField,BigAutoField,CharField,TextField,IntegerField,BooleanField,FloatField,DateTimeField,DateField,EmailField,ForeignKey - Query expressions:
eq,gt,gte,lt,lte,between,contains,startsWith,endsWith,iContains,isNull,isNotNull - Logical operators:
&(AND),|(OR) withQexpressions