# Changelog

All notable user-facing changes to `@egi/smart-db` are documented here.

## 4.0.1 - 2026-07-19

### Fixed

- Corrected the npm release process so the published package contains the production build. The npm artifact for 4.0.0 was packaged incorrectly; use 4.0.1 or newer.

## 4.0.0 - 2026-07-19

### Breaking changes

- Node.js 22 or newer is required.
- Generated models from V3 must be regenerated with the V4 `extract-db-api` CLI.
- MySQL/MariaDB and Oracle now use connection pools. Their `getDb()` methods return a pool rather than a single connection, and concurrent transaction work must use scoped transaction handles.
- The positional boolean accepted by `AbstractModel.getPlainObject()` now means `omitVirtuals`, not `includeVirtuals`. Virtual TypeScript-style fields are included by default; prefer the `GetPlainObjectOptions` object.
- `SmartDbSqlBuildData` was replaced by `SmartDbSqlBuilder`. Low-level consumers of `buildSelectStatement()` or `getLastBuildData()` must migrate to the builder API.
- `SmartDb.toDate()` moved to the exported `tools.toDate()` utility.
- Schema update scripts no longer own the sequence update in `smart_db_version`; SmartDB records a successful sequence itself. Init scripts must still insert the initial module row.
- Optional database-driver peer ranges were raised to `better-sqlite3` 12.11, `mysql2` 3.23, `oracledb` 7, and `pg` 8.22.

### Added

- First-class PostgreSQL driver and package subpath export.
- Connection pooling and dedicated transaction handles for server databases.
- `transactionWith()` for commit-on-success and automatic rollback/cleanup on failure.
- Savepoints and scoped transaction support across drivers.
- Declarative joins and bulk insert/update operations with chunking and progress callbacks.
- SQL helpers for subqueries, comparisons, conditional expressions, concatenation, rounding, truncation, and database-field aliases.
- `GetPlainObjectOptions`, extra-field capture, and optional merging of extra selected fields.
- Structured `SmartDbErrorCode` classification and improved upgrade errors.
- Browser-safe CommonJS and ESM entry points.
- Luxon `DateTime` formatting support.
- Stored-procedure `call()` support on transaction handles where supported.

### Changed

- Server drivers use session initialization for each pooled connection.
- Empty `IN([])` and `NOT_IN([])` expressions now generate deterministic always-false and always-true predicates instead of invalid SQL.
- Schema upgrades are sorted numerically, record progress after every successful script, and support safer recovery through idempotent core DDL.
- Build, test, and packaging tooling was modernized for the V4 release.

### Fixed

- Cross-driver date and timestamp handling, including operators around date fields.
- Boolean binding for abbreviated database types such as `BOOL`.
- Transaction connection cleanup and error handling across pooled drivers.
- Aggregate field translation and generated virtual-column metadata.

## 3.0.6

- Last V3 release before the V4 feature series.
