Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -25,9 +41,45 @@ Versions follow [Semantic Versioning](https://semver.org/).
- Provider-neutral `TNullable<T>` 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

Expand Down Expand Up @@ -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
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
87 changes: 87 additions & 0 deletions docs/MIGRATION.md
Original file line number Diff line number Diff line change
@@ -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<T>`, `First<T>`,
`FirstOrDefault<T>`, `Single<T>`, `SingleOrDefault<T>`, `FirstOrElse<T>`,
`SingleOrElse<T>` and `ForEach<T>` directly after `Execute`.

- `ToList<T>` returns an owning `TObjectList<T>`; 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<T>` 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<T>`
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<T>` 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).
39 changes: 38 additions & 1 deletion docs/VALIDATION.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
5 changes: 5 additions & 0 deletions docs/WEBSITE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion website/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;');
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');
Expand All @@ -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'],
Expand All @@ -41,7 +44,7 @@ function shell(title, body, source, toc = []) {
<link rel="stylesheet" href="${prefix}/assets/style.css"><link rel="icon" href="${prefix}/assets/favicon.svg" type="image/svg+xml"></head>
<body id="top"><a class="skip" href="#main">Skip to content</a><header><a class="brand" href="${relative('index.html')}"><span class="logo">Q<span>›</span></span>QueryBuilder<span class="muted">4Delphi</span></a><a href="${repo}">GitHub ↗</a></header>
<div class="layout"><aside class="sidebar"><p class="eyebrow">DEVELOPER GUIDE</p><div class="nav-scroll"><nav aria-label="Documentation">${menu.slice(0, 5).map(navLink).join('')}<details class="advanced-nav"${expanded ? ' open' : ''}><summary aria-expanded="${expanded}">Advanced</summary><div class="advanced-links">${advanced.map(navLink).join('')}</div></details></nav></div><div class="sidebar-note">Delphi 12+<br>Win32 & Win64<br><span>Six SQL dialects. One fluent API.</span></div></aside>
<main id="main" class="${source === 'converter.html' ? 'converter-page' : 'documentation'}">${body}<footer>QueryBuilder4Delphi · <a href="${repo}/blob/main/LICENSE">MIT license</a> · <a href="${prefix}/assets/third-party-licenses.txt">Third-party licenses</a>${source.endsWith('.md') ? ` · <a href="${repo}/blob/main/${source}">View Markdown source ↗</a>` : ''}</footer></main>
<main id="main" class="${source === 'converter.html' ? 'converter-page' : 'documentation'}">${body}<footer>QueryBuilder4Delphi · <a href="${repo}/releases/tag/${release}">${release}</a> · <a href="${repo}/blob/main/LICENSE">MIT license</a> · <a href="${prefix}/assets/third-party-licenses.txt">Third-party licenses</a>${source.endsWith('.md') ? ` · <a href="${repo}/blob/main/${source}">View Markdown source ↗</a>` : ''}</footer></main>
${toc.length ? `<aside class="toc"><p class="eyebrow">ON THIS PAGE</p><nav aria-label="On this page">${toc.map(h => `<a href="#${h.id}">${h.text}</a>`).join('')}</nav></aside>` : ''}</div>
<a class="back-to-top" href="#top" aria-label="Back to top" hidden><span aria-hidden="true">↑</span> Back to top</a>
<script type="module" src="${prefix}/assets/navigation.js"></script></body></html>`;
Expand Down
Loading