From 9bc05310da1c9d942fbc156b9c8efd17accc3498 Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Sat, 31 Oct 2026 20:15:49 +0100 Subject: [PATCH] Prepare v2.0.0 release and migration documentation --- CHANGELOG.md | 54 ++++++++++++++++++++++++++++ README.md | 13 +++++-- docs/API.md | 3 ++ docs/MIGRATION.md | 87 ++++++++++++++++++++++++++++++++++++++++++++++ docs/VALIDATION.md | 39 ++++++++++++++++++++- docs/WEBSITE.md | 5 +++ website/build.mjs | 5 ++- 7 files changed, 202 insertions(+), 4 deletions(-) create mode 100644 docs/MIGRATION.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 74c9d9b..f2539b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,22 @@ Versions follow [Semantic Versioning](https://semver.org/). ## [Unreleased] +## [2.0.0] - 2026-10-31 + +Object mapping, nullable DTO round trips, parameterized fluent compilation and +a documentation website with a browser-local SQL-to-Delphi converter. + +### Breaking changes and migration + +- `IQuery.Compile` returns `ISqlResult` instead of a substituted SQL string. + Use `.Compile(Dialect).Sql` together with `.Bindings` for execution, or + `.ToDebugSql(Dialect)` for the previous diagnostic preview behavior. +- `IQuery.Execute` returns the `TQueryResult` record facade instead of + `IQueryResult`. Direct interface assignments still work; use `.AsRaw` when + an explicit interface is needed. Custom `IQuery` implementations must adopt + both return types. Rebuild dependent units and packages. +- See the [v1 migration guide](docs/MIGRATION.md) for examples and ownership rules. + ### Changed - `IQuery.Compile` now returns `ISqlResult` with parameterized SQL and bindings. @@ -25,9 +41,45 @@ Versions follow [Semantic Versioning](https://semver.org/). - Provider-neutral `TNullable` with automatic mapping for built-in types, operation-scoped registrations for custom types, optional NULL assignment skipping and exact-pair converters. +- Provider-independent RTTI object mapping with shared `[Column]`, `[Key]` and + `[Ignore]` attributes, schema validation and contextual mapping errors. +- Fluent `ToList`, `First`, `FirstOrDefault`, `Single`, `SingleOrDefault`, + `FirstOrElse`, `SingleOrElse` and `ForEach` mapping methods, plus static + `MapCurrent` for caller-positioned cursors. Terminal calls release their + consumed result reference deterministically; lazy fallbacks run only for + empty results and streaming callbacks borrow one object at a time. +- Explicit SQL NULL policies: type defaults (`nmbDefault`), strict errors + (`nmbThrow`) or preservation of constructor values (`nmbSkip`). Nullable + properties retain the distinction between NULL and zero/False/empty values. +- Nullable DTO values in object INSERT, UPDATE, WHERE and HAVING, including + typed SQL NULL bindings, `IS NULL` predicates and rejection of NULL UPDATE + keys. FireDAC supports native SQL timestamp/offset parameter values. - Checked signed/unsigned integer and exact integer/float conversions; native BCD, SQL timestamp/offset, GUID and byte-array mapping; exact Currency/BCD conversion with precision and overflow checks. +- Mapping benchmarks for Win32/Win64, expanded DUnitX regressions and compiled + examples for mapping, nullable round trips and fluent search. +- XML documentation throughout the public API and generated declarations, + with a repeatable coverage audit and behavior-specific generator tests. +- GitHub Pages documentation generated directly from repository Markdown, + with syntax highlighting, heading links, responsive navigation and search + examples. Browser interaction tests cover desktop and mobile layouts. +- Browser-local SELECT-to-Delphi conversion for MySQL, PostgreSQL, SQL Server + and SQLite, with highlighted SQL/Delphi editors, exact numeric range checks, + unsupported-syntax errors, copy support and generated Delphi smoke projects. + The converter processes input in memory without uploading or persisting it. + +### Validation + +- Release checks and their scope are recorded in + [validation details](docs/VALIDATION.md#v200-release-validation-2026-10-31). +- Existing Delphi executables rerun: 940 Core and 94 FireDAC tests passed on + each of Win32 and Win64, with zero failures, errors, ignored tests or leaks. + These are reruns of the October 25 IDE builds, not fresh release builds. +- All 67 JavaScript tests, 10 browser tests, website build/link checks, 15 + Python tests, generator checks and the XML documentation audit passed. +- Database integration coverage uses SQLite in memory; other dialects have SQL + compilation/binding coverage rather than live server validation. ## [1.0.0] - 2026-10-23 @@ -74,4 +126,6 @@ Delphi 12 and later on Windows (Win32 and Win64). covered by SQL compilation and binding tests; server-specific execution was not tested. See [validation details](docs/VALIDATION.md). +[Unreleased]: https://github.com/auchri/QueryBuilder4Delphi/compare/v2.0.0...HEAD +[2.0.0]: https://github.com/auchri/QueryBuilder4Delphi/releases/tag/v2.0.0 [1.0.0]: https://github.com/auchri/QueryBuilder4Delphi/releases/tag/v1.0.0 diff --git a/README.md b/README.md index 3063326..2984fd0 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,17 @@ QueryBuilder4Delphi is a fluent SQL query builder for Delphi 12 and later. It su Supported targets: **Windows, Win32 and Win64**. Build SQL without a database, or execute it through the optional FireDAC provider or your own provider. -Current release: **[v1.0.0](https://github.com/auchri/QueryBuilder4Delphi/releases/tag/v1.0.0)**. -See the [changelog](CHANGELOG.md) for release details. +Current release: **[v2.0.0](https://github.com/auchri/QueryBuilder4Delphi/releases/tag/v2.0.0)**. +See the [changelog](CHANGELOG.md) for release details and the +[migration guide](docs/MIGRATION.md) when upgrading from v1.0.0. + +**[Documentation website](https://auchri.github.io/QueryBuilder4Delphi/)** · +**[SQL → Delphi converter](https://auchri.github.io/QueryBuilder4Delphi/converter.html)** + +Version 2 adds fluent object mapping, nullable read/write DTOs and explicit SQL +NULL policies. `Compile` now returns parameterized SQL and bindings; +`ToDebugSql` provides the diagnostic preview. The browser-local converter turns +supported SELECT queries into fluent Delphi code for four input dialects. ## Installation diff --git a/docs/API.md b/docs/API.md index 225632f..2758bfb 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1,5 +1,8 @@ # API reference and limitations +This reference describes v2.0.0. For changes to `Compile` and `Execute`, see +the [migration guide from v1.0.0](MIGRATION.md). + ## Execution and optional FireDAC provider The query describes the operation; the compiler generates parameterized SQL; diff --git a/docs/MIGRATION.md b/docs/MIGRATION.md new file mode 100644 index 0000000..b05611b --- /dev/null +++ b/docs/MIGRATION.md @@ -0,0 +1,87 @@ +# Upgrade from v1.0.0 to v2.0.0 + +Version 2 adds object mapping, nullable DTO reads and writes, and a +[documentation website and SQL converter](WEBSITE.md). Two public return types +changed. Rebuild all dependent units and packages after updating `src`. +The minimum target remains Delphi 12 on Windows, Win32 or Win64. + +## Compile returns SQL and bindings + +In v1, `Query.Compile(Dialect)` returned a string with values substituted. +In v2 it returns `ISqlResult`, declared in `QueryBuilder4Delphi.Query.Core`: + +```delphi +var + Statement: ISqlResult; +begin + Statement := TQuery.Create('Books').Where('Id', 42) + .Compile(TSqlDialect.MSSql); + // Pass Statement.Sql AND Statement.Bindings to your database adapter. +end; +``` + +For the previous diagnostic string behavior, replace +`Preview := Query.Compile(Dialect)` with +`Preview := Query.ToDebugSql(Dialect)`. `Statement.ToString` also produces a +substituted preview. Previews are intended for diagnostics; execute the +parameterized SQL with its ordered bindings. The default dialect remains MSSql. +`ICompiler.Compile` is unchanged. The compiler unit retains an `ISqlResult` +type alias with the original interface GUID. + +## Execute returns a record facade + +`IQuery.Execute` now returns `TQueryResult`, which wraps an `IQueryResult` and +delegates its reader methods. Existing assignments to an explicitly declared +`IQueryResult` continue to work through implicit conversion: + +```delphi +var + Rows: IQueryResult; +begin + Rows := TQuery.Create('Books').Execute(Executor); + while Rows.Next do + Writeln(Rows.GetValue('Title').AsString); +end; +``` + +Use `.Execute(Executor).AsRaw` to request the interface explicitly. Inferred +variables now hold a record; clear them with `Default(TQueryResult)` rather +than `nil`. A `var` or `out` interface argument needs an actual `IQueryResult` +variable. Custom `IQuery` implementations must update both `Compile` and +`Execute` signatures; custom executors still return `IQueryResult` unchanged. + +## Mapping methods and ownership + +Import `QueryBuilder4Delphi.Mapping` to use `ToList`, `First`, +`FirstOrDefault`, `Single`, `SingleOrDefault`, `FirstOrElse`, +`SingleOrElse` and `ForEach` directly after `Execute`. + +- `ToList` returns an owning `TObjectList`; free the list after use. +- Single-object results belong to the caller. Lazy fallback references retain + their existing ownership and run only when the result is empty. +- `ForEach` lends each mapped object only during its callback. +- Fluent terminal methods consume their receiving facade and release its + result reference before returning, including on errors. Copies and retained + raw interfaces share the cursor and keep their own references alive. +- Static `TQueryMapper` methods remain available, including `MapCurrent` + for a cursor already positioned on a row. + +See [mapping compatibility](OBJECT_MAPPING.md#result-facade-and-compatibility) +for helper selection, retained references and error behavior. + +## SQL NULL and shared DTO attributes + +The new mapper defaults to `nmbDefault`: SQL NULL overwrites constructor values +with the supported Delphi type's default. Configure `TQueryMappingOptions` with +`nmbThrow` for strict errors or `nmbSkip` to preserve constructor values. +Use `TNullable` from `QueryBuilder4Delphi.Nullable` to distinguish SQL NULL +from zero, False or empty values. Nullable properties receive `.Null` under +all three policies and can also be used in object INSERT, UPDATE, WHERE and +HAVING. NULL UPDATE keys are rejected. + +Read and write mapping share `[Column]`, `[Key]` and `[Ignore]` resolution. +Blank names, case-insensitive column collisions and conflicting attributes +are rejected before object-write getters or key callbacks run. Review DTOs +that previously relied on ambiguous names. See the +[shared attribute rules](OBJECT_MAPPING.md#shared-readwrite-attributes) and +[nullable write examples](OBJECT_MAPPING.md#writing-nullable-properties). diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index c6eefc4..b9fc622 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -1,4 +1,41 @@ -# Validation: October 25, 2026 +# Validation + +## v2.0.0 release validation (2026-10-31) + +The release changes documentation and website release metadata on top of +`4b87528` (main, including PR #30). Library and test sources are unchanged. + +The existing Delphi 12 Community Edition executables were rerun with +`tools/build.ps1 -Suite Core/FireDAC -Platform Both -TestsOnly`: + +| Suite | Win32 passed | Win64 passed | Failed/errors/ignored/leaked | +| --- | ---: | ---: | --- | +| Core without FireDAC | 940 | 940 | 0/0/0/0 | +| FireDAC / SQLite | 94 | 94 | 0/0/0/0 | + +These are reruns of the October 25 IDE builds, not fresh release builds. +The existing JSON validation records below describe their original feature +snapshots; they have not been relabeled as release-build evidence. +Database integration uses SQLite in memory and FireDAC memory fields; +no live validation against the other five database servers is claimed. + +Additional release checks passed: + +- All 67 JavaScript converter, numeric, state, token and smoke-fixture tests. +- Static website build and all generated local links and heading anchors. +- All 10 Playwright browser tests using installed Microsoft Edge, including + keyboard/copy behavior and layouts from 320 to 1920 pixels. +- Both generator `--check` commands (including 69 paired Oracle scenarios), + all 15 Python generator tests and the public XML documentation audit + (zero errors). +- `git diff --check`. + +Generated converter smoke projects are covered by JavaScript fixture checks. +Full native compilation/execution +of all four generated projects on both platforms remains unverified; the +local artifacts contain only a MySQL Win32 executable. + +## Previous validation: October 25, 2026 ## SQL NULL mapping policy (issue #20) diff --git a/docs/WEBSITE.md b/docs/WEBSITE.md index e6ea25a..b1aff43 100644 --- a/docs/WEBSITE.md +++ b/docs/WEBSITE.md @@ -12,6 +12,11 @@ point back to GitHub. The generated pages include syntax highlighting, an on-page contents list, and a link to their original Markdown source. The generated `website/dist/` directory is ignored by Git. +The footer on every page links to the current GitHub release. Its version is +read from the `Current release` declaration in `README.md`, so updating that +declaration also updates the website. The changelog and +[v2 migration guide](MIGRATION.md) are available through the Advanced menu. + ## Local development Requires Node.js 24 and npm. From the repository root: diff --git a/website/build.mjs b/website/build.mjs index 71faf1e..54c00fc 100644 --- a/website/build.mjs +++ b/website/build.mjs @@ -10,6 +10,8 @@ export const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ' const site = path.join(root, 'website'); export const output = path.join(site, 'dist'); const repo = 'https://github.com/auchri/QueryBuilder4Delphi'; +const release = (await readFile(path.join(root, 'README.md'), 'utf8')).match(/Current release: \*\*\[(v\d+\.\d+\.\d+)\]/)?.[1]; +if (!release) throw new Error('README.md must declare the current release.'); const escape = s => String(s).replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"'); export const documents = ['README.md', 'CHANGELOG.md', ...(await readdir(path.join(root, 'docs'))).filter(f => f.endsWith('.md')).map(f => `docs/${f}`)]; const target = source => source === 'README.md' ? 'index.html' : source.replace(/\.md$/, '.html'); @@ -24,6 +26,7 @@ const menu = [ ['README.md', 'Overview'], ['converter.html', 'SQL → Delphi'], ['docs/EXAMPLES.md', 'Examples'], ['docs/API.md', 'API reference'], ['docs/OBJECT_MAPPING.md', 'Object mapping'], ['docs/PORTING.md', 'Porting'], + ['docs/MIGRATION.md', 'Upgrade to v2'], ['docs/VALIDATION.md', 'Validation'], ['docs/XML_DOCUMENTATION.md', 'XML documentation'], ['docs/MAPPING_PERFORMANCE.md', 'Mapping performance'], ['CHANGELOG.md', 'Changelog'], ['docs/WEBSITE.md', 'Website maintenance'], @@ -41,7 +44,7 @@ function shell(title, body, source, toc = []) {
QueryBuilder4DelphiGitHub ↗
-
${body}
+
${body}
${toc.length ? `` : ''}
`;