Releases: gosoline-project/sqlr
Releases · gosoline-project/sqlr
Release list
v0.8.2
Highlights
- Preserves transient in-memory fields when entities are rehydrated after
create and update flows, preventing non-persisted state from being lost.
Improvements
- Tightens rehydration behavior so mutation flows return fully refreshed
entities without discarding caller-managed transient data.
API cleanup
- No API changes in this release.
Internal changes
- Reorganizes association coverage into dedicated create, update, delete,
tx, and shared fixture test files for easier maintenance.
v0.8.1
Highlights
- This release does not introduce new user-facing features; it prepares the repository for easier downstream testing and interface-based integration work.
Improvements
- No behavior changes are included beyond the previously published
v0.8.0release.
API cleanup
- No public API changes are included in this release.
Internal changes
- Added generated mocks for repository interfaces to improve test ergonomics and make internal verification of repository interactions easier to maintain.
v0.8.0
Highlights
- Created entities now reload through the same rehydration path as updates, so requested preloads and auto-preloaded relations are returned from persisted data immediately after create operations.
- Repository and transaction write flows now hydrate belongs-to and many-to-many associations consistently after inserts, reducing follow-up queries and mismatched post-write state.
Improvements
- Create operations now honor post-write preload behavior consistently with update operations, making relation loading after inserts more predictable.
- Shared mutation preload validation and reload helpers reduce divergence between repository and transaction code paths.
API cleanup
- No public API surface was removed, but create-time reload behavior now matches update semantics more closely when preloads or auto-preloads are configured.
Internal changes
- Refactored mutation reload handling into shared helpers reused by both create and update flows.
- Expanded repository, transaction, query builder, and association test coverage for create-side reload and preload scenarios.
v0.7.0
Highlights
- Added post-update preloading support so update workflows can immediately hydrate requested relations after persistence.
- Updated entities now reload automatically when sync behavior or explicit preloads are configured, making update results more consistent with create and query flows.
Improvements
- Improved repository update behavior to return fully refreshed entities when association syncing or preload options are in use.
- Tightened update execution around prepared statements by using context-aware query execution paths.
API cleanup
- No breaking API changes in this release.
Internal changes
- Expanded repository and transaction test coverage for update preload hydration and association reload behavior.
- Refined the update pipeline internals to support post-update reloads without changing the public release workflow.
v0.6.0
Highlights
- Split repository metadata into dedicated
sqlrstruct tags, making entity definitions clearer and keeping column mapping indbtags. - Added schema-level association sync defaults and aligned
sync:tag syntax withsqlh, including support for nestedsync:deletedefaults. - Added
Createsupport for omitting all associations in a single call, and made owned-association cleanup cascade by default during deletes.
Improvements
- Made many-to-many updates link-only by default to avoid unintended row mutations in related tables.
- Fixed has-one updates so cleared relations are persisted correctly.
- Updated prepared statement handling to work with
sqlcv0.3.0 and the newer client API. - Tightened schema parsing by rejecting unexported fields with
sqlrmetadata.
API cleanup
sqlrmetadata is now expected insqlrtags instead of being mixed intodbtags.sqlrtag options must now be separated with semicolons.- Association sync behavior has been normalized around the
sync:option model, which may require tag updates in existing entities.
Internal changes
- Simplified schema parsing helpers and cleaned up lint issues.
- Expanded repository and schema coverage around association lifecycle, delete behavior, preload handling, and prepared statements.
- Updated the bundled
sqlcdependency tov0.3.0.
v0.5.0
Highlights
- Add fixture writer helpers for
gosolinefixture sets, making it easier for applications built onsqlrto load deterministic integration-test data with caller-managed IDs and timestamps. - Add
DisableAutoUpdateswrite controls so create and update flows can preserve caller-supplied IDs, timestamps, and association fields when needed. - Export schema parsing helpers and add type-based schema parsing, making it easier to build reflection-driven integrations on top of
sqlr. - Introduce canonical relation path resolution so preloads, joins, and association sync follow the same nested path rules.
Improvements
- Restore entity IDs, timestamps, and foreign keys after failed writes so in-memory entities do not remain partially mutated.
- Tighten automatic relationship detection to reduce false positives for untagged value objects and incomplete foreign key setups.
- Reject conflicting scalar join rows while still deduplicating exact duplicates for more predictable join hydration.
API cleanup
- Standardize schema and relation-path handling around the exported parsing helpers for more consistent behavior across generic and reflection-based callers.
- No breaking API removals are included in this release.
Internal changes
- Split association internals into focused modules and centralize helper context handling to simplify maintenance.
- Expand coverage for preload failures, transactional repository paths, prepared statement lifecycle errors, and fixture loading workflows.
v0.4.0
Highlights
- Added selective association sync controls for create and update flows, allowing specific association paths to be synced or omitted with finer control.
- Improved association persistence so existing has-one and has-many children are linked correctly during create operations.
- Expanded relation handling with better support for pointer-based relations, pointer auto timestamps, and zero-valued relation keys.
Improvements
- Fixed joined reads to avoid truncating results when joins are involved.
- Fixed cases where joined queries could skip preloads.
- Improved preload execution safety by deduplicating paths and only parallelizing independent branches.
- Hardened schema validation and relation persistence behavior.
- Removed the hidden ID-setter requirement during create by falling back to reflective primary key assignment when needed.
- Added clearer error handling for nil entities and better guarding for nil relation conditions.
- Improved update-not-found handling and prepared statement validation in transactional flows.
API cleanup
- Removed unsupported
RightJoinandCrossJoinbuilder APIs to align the public surface with supported behavior.
Internal changes
- Refactored association synchronization, persistence helpers, and relation wrappers to simplify the implementation.
- Expanded regression coverage across association, preload, schema, transaction, read, create, and update behavior.
- Applied general lint and test cleanups.
v0.3.0
Highlights
- update gosoline to v0.57.2 and sqlc to v0.2.0
- add GitHub Actions CI checks for build, test, and lint
- align lint and mockery configuration with the updated toolchain
Changes since v0.2.0
- refresh transitive Go module dependencies after the version bumps
- update .golangci.yml and .mockery.yml to match the current setup
v0.2.0
New Features
Global SchemaNameTransformer
A new package-level SchemaNameTransformer variable (default: toSnakeCase) controls how Go identifiers (struct type names, field names) are converted to database identifiers (table names, column names, M2M join-column names). It can be replaced at program startup to apply custom naming conventions.
// Use lowercase field names instead of snake_case:
sqlr.SchemaNameTransformer = strings.ToLowerAuto-Detection of Untagged Relationships
Public struct and slice-of-struct fields no longer require a db tag to be recognized as relationships:
- Non-slice struct field →
BelongsTo, FK derived asSchemaNameTransformer(fieldName) + "_id" - Slice-of-struct field →
HasMany, FK derived asSchemaNameTransformer(parentTypeName) + "_id"
Standard library value types (time.Time, sql.NullString, net.IP, etc.) are excluded from auto-detection and treated as plain columns. The exclusion list (valueTypePackages) can be extended at startup.
type Post struct {
Entity[int64]
AuthorID int64 // column "author_id" via SchemaNameTransformer
Author Person // auto-detected as BelongsTo, FK = "author_id"
}
type Person struct {
Entity[int64]
Posts []Post // auto-detected as HasMany, FK = "person_id"
}ManyToMany Join Table & Column Overrides
- Auto-derived join table name: when
many2many:tag value is empty, the join table name is automatically derived by sorting both entity table names alphabetically and joining them with an underscore. parentKey:/relatedKey:tag options: new tag options allow overriding the join table column names that reference each side's primary key.
type Article struct {
Entity[int64]
Tags []Tag `db:"-,many2many:,parentKey:article_pk,relatedKey:tag_pk"`
}Improvements
toSnakeCasedigit handling: correctly inserts underscores after digit sequences followed by uppercase letters (e.g.,Uint64Article→uint64_article).- Runtime
tableNameForType: derives table names fromreflect.Typeat runtime, respecting both theTableNamerinterface andSchemaNameTransformerin all reflection-driven code paths. - M2M column name resolution: ManyToMany join column derivation now goes through
SchemaNameTransformerconsistently across both preload and association/create code paths.
Testing
- 15 new schema tests covering non-struct type errors, missing PK errors, pointer-to-struct unwrapping, string PKs in insert columns, HasOne, ManyToMany, mixed preload, and auto-detected relationships.
- Expanded preload, query builder, and read test coverage with doc comments on all test methods.