bavard 0.0.27
bavard: ^0.0.27 copied to clipboard
An Eloquent-inspired ORM for Flutter. Supports SQLite, PostgreSQL and PowerSync with fluent queries, relationships, soft deletes, timestamps, casts and more.
Changelog #
All notable changes to this project will be documented in this file.
[Unreleased] #
0.0.27 - 2026-01-07 #
Added #
- Core: Added
stackTracesupport toBavardExceptionand all its subclasses. This ensures that when database errors or transaction failures are caught and rethrown, the original stack trace is preserved for easier debugging. - Core: Added
formatBoolForDebug()toGrammarto support dialect-specific boolean formatting (e.g.,TRUE/FALSEfor Postgres vs1/0for SQLite) in debug SQL output. - Testing: Updated
MockDatabaseSpyconstructor to accept an optionalGrammar, enabling better testing of dialect-specific behaviors in unit tests.
Changed #
- Generator: Migrated to
SharedPartBuilderfor code generation. - Pivots: Standardized the
Pivotconstructor pattern toUserRole([Map<String, dynamic> attributes = const {}]) : super(Map.from(attributes)). This ensures better isolation of pivot data and supports parameterless instantiation.
Documentation #
- Theme: Applied glassmorphism style to the navigation bar for better readability.
- Fun: Added a surprise "quack" on the homepage for curious clickers. 🪿
- Reference: Updated "Error Handling" guide to document the new
stackTraceproperty and how to use it for debugging.
Fixed #
- Core: Improved SQL generation for
HasSoftDeletesand relationships (BelongsTo,HasMany, etc.) by fully qualifying column names with their table aliases (e.g.users.deleted_atinstead ofdeleted_at). This prevents "ambiguous column name" errors in complex queries involving joins. - Core: Fixed
QueryBuilder.toSql()andtoRawSql()to correctly apply global scopes (like soft deletes) before compiling the SQL. - Core: Fixed a bug in
QueryBuilder.toRawSql()where placeholder replacement (?) was incorrectly applied to points of domanda inside string literals. It now uses a safer parser that respects string boundaries.
0.0.26 - 2026-01-05 #
Added #
- Core: Added
insertAll()method toQueryBuilderfor high-performance bulk record insertion. It generates a single SQL query (VALUES (...), (...)) and bypasses model events for efficiency. - Core: Added
cursor({int batchSize})method toQueryBuilderfor lazy streaming of large datasets using offset-based pagination. This allows iterating over thousands of records without loading them all into memory at once. - Core: Added support for SQL Set Operations:
union(),unionAll(),intersect(), andexcept(). These methods allow combining results from multiple queries with automatic binding aggregation and proper SQL generation. - Relations: Added support for Conditional Eager Loading.
withRelationsnow accepts aMap<String, ScopeCallback>where the value is a callback to apply constraints (e.g.where) to the eager loading query.
0.0.25 - 2025-12-31 #
Documentation #
- Reference: Updated "Database Adapters" guide to reflect the new simplified
DatabaseAdapterinterface and explained thatwatchlogic is now handled by the core. - Readme: Enhanced the project README with a comprehensive "Quick Start" guide, database initialization steps, and a dedicated "Relationships" section.
0.0.24 - 2025-12-31 #
Refactor #
- Core: Implemented database-agnostic
watch()functionality. The logic for tracking table changes and notifying listeners has been moved from individual adapters to the centralDatabaseManager. - Core:
DatabaseManagernow handles notification buffering during transactions. Table changes are only emitted towatchstreams after a transaction is successfully committed, preventing dirty reads. - Adapters: Simplified
DatabaseAdapterinterface by removing watch-specific methods, making it easier to implement new database drivers.
Added #
- Testing: Added comprehensive tests for
watchbehavior within transactions (commit/rollback scenarios) intransaction_test.dartandwatch_test.dart.
0.0.23 - 2025-12-27 #
Added #
- Core: Support for Custom Attribute Casts via the
AttributeCast<T, R>interface. - Core: Added smart Dirty Checking for Timestamps.
updated_atis now only updated if the model has other dirty attributes, preventing redundant queries. - Schema: Standard columns (
IdColumn,CreatedAtColumn, etc.) now have default names, enabling zero-config automatic casting. - Testing: New Shared Integration Test Suite in
example/shared_test_suite. - Testing: Added 5 new integration scenarios: Concurrency, Blob support, Unique constraints, UTC Date handling, and Dirty Checking optimization.
- Tooling: Added
make test-allto theMakefilefor a full one-shot test execution (Unit + SQLite + Postgres).
Improved #
- Adapters: Enhanced
PostgresAdapterto handle binary data (Blobs) usingTypedValueand fixed SQL placeholder interpolation. - Core: Refactored
HasTimestampsto use the internal casting system instead of raw attribute access.
0.0.22 - 2025-12-27 #
Added #
- Core: Refactored
HasCaststo automatically derive casting rules from thecolumnslist (Schema), eliminating the need for a manualcastsmap in most cases. - Documentation: Updated "Type Casting" and "Model" guides to prioritize schema-driven casting and added examples for manual implementations.
Improved #
- Core: Enhanced internal type mapping between SQL schema types (
integer,boolean,doubleType) and Dart runtime types (int,bool,double).
0.0.21 - 2025-12-27 #
0.0.18 - 2025-12-26 #
Added #
- Schema: Added
IdColumn,CreatedAtColumn,UpdatedAtColumn, andDeletedAtColumnto enable fully type-safe queries on standard fields. - Mixins: Added typed getters/setters (
createdAt,updatedAt,deletedAt) directly toHasTimestampsandHasSoftDeletesmixins. - QueryBuilder: Implemented dynamic column name resolution. Standard columns in the schema (e.g.
User.schema.id) now automatically resolve to the model's actual configuration (e.g.primaryKey) at runtime.
Improved #
- Generator: The
@fillablegenerator now intelligently ignores standard columns if the corresponding mixins are present, preventing code duplication and conflicts. - Schema: Refactored
Columnhierarchy to support polymorphic column lists viaSchemaColumninterface, fixing type variance issues in many-to-many pivots. - Documentation: Updated code generation guide to showcase the new concise schema definition style and explained standard column behavior.
Documentation #
- Core: Clarified that code generation is completely optional; Bavard is designed to work entirely at runtime using standard Dart syntax.
- Guides: Added comprehensive instructions for manual model and pivot class implementation (without
build_runner). - Home: Updated features list to highlight "Zero boilerplate", "Offline-first", and "Smart Data Casting".
- API Reference: Reorganized documentation to distinguish between core (included) and optional mixins.
0.0.17 - 2025-12-24 #
Added #
- Relations: Added
attach()anddetach()methods toBelongsToManyfor easy management of many-to-many relationships. - Examples: Added a comprehensive PostgreSQL + Docker integration test suite in
example/postgresql-docker. - Core: Allow
Columnobjects as keys ininsertandupdatemethods. - Tests: Added dedicated unit tests for
BelongsToManyattach/detach operations.
Improved #
- Core: Enhanced
QueryBuilder.avg()to robustly handle numeric string results, improving compatibility with PostgreSQL numeric types. - Examples: Refactored
sqlite-dockerandpostgresql-dockerexamples to eliminate raw SQL queries in favor of ORM-native methods.
Fixed #
- Core: Quote table and column names in SQL queries to prevent syntax errors.
Changed #
- Dependencies: Update project dependencies.
- Tests: Update mocks for database grammar wrap.
0.0.11 - 2025-12-24 #
0.0.10 - 2025-12-24 #
Added #
- Core: Enhanced
QueryBuilderwith comprehensive support forColumnobjects across all methods (select,where,groupBy,orderBy,count,sum, etc.), enabling fully type-safe queries. - Core: Added automatic table prefixing (e.g.,
"users"."id") when usingColumnobjects to prevent column ambiguity during joins. - Core: Added
whereColumnandorWhereColumnmethods for comparing two columns. - Core: Added
whereBetween,orWhereBetween,whereNotBetween, andorWhereNotBetweenmethods. - Relations: Added support for
Columnobjects inBelongsToManypivot filters (wherePivot,withPivot, etc.) with automatic pivot table prefixing. - Security: Added strict validation and helpful error messages when passing invalid arguments (like
WhereCondition) toQueryBuildermethods.
Fixed #
- Documentation: Fixed 404 error on API index page and improved navigation.
- Core: Fixed identifier quoting in aggregate functions for better dialect compatibility.
0.0.7 - 2025-12-24 #
Added #
- Core: Added Dirty Checking support to
Model(isDirty(),getDirty()) for optimized updates. - Relations: Added
hasManyThroughPolymorphicto natively support distant polymorphic relations. - Utils: Improved
singularizeutility to handle common English rules (e.g.-es,-ies, irregulars) without external dependencies. - Examples: Added a comprehensive SQLite + Docker integration test suite in
examples/sqlite-docker. - Documentation: Added detailed guides for "Constraining Relations", "Polymorphic HasManyThrough", and "Dirty Checking".
0.0.6 - 2025-12-23 #
Added #
- Relations: Added support for nested relations (e.g.,
user.posts.comments) in eager loading and querying.
0.0.5 - 2025-12-23 #
Changed #
- Documentation: Updated import examples in guide and index page.
- Core: Removed unused imports and cleaned up code.
0.0.4 - 2025-12-23 #
Added #
- Pivots: Added typed pivot support for many-to-many relations, allowing type-safe access to pivot data.
- Pivots: Allowed retrieving extra pivot columns without requiring a custom pivot class definition.
- Documentation: Added reference implementations for database adapters.
Changed #
- Core: Reworked attribute casting and hydration logic for better performance and reliability.
- Core: Refactored code generation annotations and logic for consistency.
- Pivots: Improved pivot type casting and added setter support.
- Pivots: Updated pivot schema definitions to use static records for cleaner syntax.
0.0.3 - 2025-12-23 #
Added #
- Core: Introduced
Grammarstrategy pattern for SQL dialect abstraction, supporting SQLite and Postgres. - Core: Implemented AST-based schema parser for fillable generator.
- Documentation: Added initial project documentation with VitePress.
- CI: Added GitHub Actions workflow to deploy documentation.
Changed #
- Core: Overhauled
whereclause with typed column objects and conditions. - Core: Refactored imports and exports for cleaner library structure.