jao 0.3.6
jao: ^0.3.6 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.6 - 2026-03-16 #
Fixed #
- String default values in SQL are now properly quoted (
DEFAULT '{}'instead ofDEFAULT {})- Added
sqlDefault()helper that wraps non-numeric, non-boolean, non-keyword values in SQL single quotes - Escapes embedded single quotes using SQL standard
''doubling - Applied at all SQL emission points:
CreateTable,AddColumn,AlterColumn, and SQLite table recreation
- Added
0.3.5 - 2026-03-16 #
Added #
ColumnModificationnow storespreviousTypeandpreviousDefaultfor reversible migrations- The diff engine captures the DB column's current state when creating
AlterColumnoperations - Reverse code generator produces correct
down()methods for type changes, default value changes, and default drops - Rename, nullability, type, and default value
AlterColumnoperations are all now reversible
- The diff engine captures the DB column's current state when creating
0.3.4 - 2026-03-16 #
Changed #
ModelFieldSchema.defaultValuetype changed fromString?toObject?- Default values now stay typed (
bool,int,double,String) through the pipeline _addFieldToBuilderuses pattern matching instead of string parsing for default valuestoString()is applied only at the SQL boundary (ColumnDefinition,ColumnModification)
- Default values now stay typed (
0.3.3 - 2026-03-16 #
Fixed #
AddForeignKeyandDropConstraintoperations now work on SQLite via table recreation- SQLite does not support
ALTER TABLE ... ADD CONSTRAINTorDROP CONSTRAINT - Both operations now use the existing
generateTableRecreationSqlapproach (rename, recreate, copy data, drop old)
- SQLite does not support
- Schema pre-fetch for SQLite table recreation now includes
AddForeignKeyandDropConstraintoperations (previously onlyAlterColumnwas pre-fetched)
0.3.2 - 2026-03-16 #
Fixed #
- Migration diff now detects changes to existing columns beyond just nullability and type:
- Default value added, changed, or removed — generates
SET DEFAULTorDROP DEFAULT - Column length (
maxLength) changes for varchar/char columns - Decimal
precision/scalechanges (when the database reports them) - Missing unique constraints — generates
CREATE UNIQUE INDEX - Missing foreign key constraints — generates
ADD CONSTRAINT ... FOREIGN KEY
- Default value added, changed, or removed — generates
0.3.1 - 2026-03-15 #
Fixed #
- UUID primary key columns not being created in migrations (#33)
@UuidPrimaryKey()fields were skipped by_addFieldToBuilderbecause they haveprimaryKey: truebutautoIncrement: false- Added explicit handling for UUID PKs via
builder.uuid()
- Migration code generator (
_columnToCode) now explicitly handles allFieldTypevariants instead of falling through to a default comment- Previously unhandled types (uuid, char, smallInt, bigInt, real, doublePrecision, decimal, date, time, timestamp, json, jsonb, bytea, blob, interval, array) were silently output as comments
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