|
Lightweight 0.20260303.0
|
Opt-in behavioural knobs that the ToSql migration-plan renderer honours.
More...
#include <MigrationPlan.hpp>
Classes | |
| struct | ColumnKey |
| struct | TableKey |
| Tables for which the lookup has already been attempted, so we don't re-query for every INSERT against the same table. More... | |
Public Types | |
| enum class | WidthUnit : uint8_t { Characters , Bytes } |
| How a column's declared width is counted. The truncation layer must match the server's interpretation: a VARCHAR(100) on MSSQL holds 100 bytes, but an NVARCHAR(100) holds 100 characters. Truncating to 100 characters when the server budget is 100 bytes still overflows on multi-byte source data. More... | |
Public Attributes | |
| bool | lupTruncate = false |
| std::map< ColumnKey, ColumnWidth > | columnWidths |
| Cache of declared character widths, populated lazily as plan elements render. | |
| std::function< void(MigrationRenderContext &, std::string_view, std::string_view)> | widthLookup |
Optional fallback that fetches column widths for a (schema, table) from the live database when the cache has no entry for it. | |
| std::set< TableKey > | lookupAttempted |
Tables for which widthLookup has already been called; prevents repeat queries. | |
| std::string | activeMigrationTitle |
Identity of the migration currently being rendered. Set by MigrationManager::ApplySingleMigration before ToSql is called for each step so warnings (e.g. lup-truncate) can attribute themselves to the offending migration. Empty / zero when rendering happens outside a migration run (e.g. unit tests calling ToSql directly). | |
| std::uint64_t | activeMigrationTimestamp = 0 |
| Timestamp of the migration currently being rendered (0 outside a migration run). | |
Opt-in behavioural knobs that the ToSql migration-plan renderer honours.
When a profile declares a compat: flag (see Lightweight::Config::CompatFlags), dbtool / dbtool-gui construct one of these and pass it alongside the formatter so migration rendering can diverge from strict behaviour per-run.
The context is mutable across successive ToSql calls within the same migration run: it accumulates a column-width cache populated from CreateTable / AlterTable steps as they are rendered, so later Insert / Update steps can truncate oversize values without a server round-trip.
Default-constructed instances are strict (no truncation, no logging); this is the shape used by code paths that don't care about compat, so existing callers keep their behaviour.
Definition at line 573 of file MigrationPlan.hpp.
|
strong |
How a column's declared width is counted. The truncation layer must match the server's interpretation: a VARCHAR(100) on MSSQL holds 100 bytes, but an NVARCHAR(100) holds 100 characters. Truncating to 100 characters when the server budget is 100 bytes still overflows on multi-byte source data.
Definition at line 598 of file MigrationPlan.hpp.
| bool Lightweight::MigrationRenderContext::lupTruncate = false |
When true, string values in Insert / Update steps are truncated to the destination column's declared character width and the truncation is logged via SqlLogger::OnWarning. Mirrors LUpd's client-side clipping behaviour; see Lightweight::Config::CompatFlagLupTruncate.
Definition at line 579 of file MigrationPlan.hpp.
| std::map<ColumnKey, ColumnWidth> Lightweight::MigrationRenderContext::columnWidths |
Cache of declared character widths, populated lazily as plan elements render.
Definition at line 611 of file MigrationPlan.hpp.
| std::function<void(MigrationRenderContext&, std::string_view , std::string_view )> Lightweight::MigrationRenderContext::widthLookup |
Optional fallback that fetches column widths for a (schema, table) from the live database when the cache has no entry for it.
The renderer calls this once per (schema, table) it can't satisfy from columnWidths. Implementations should issue a single INFORMATION_SCHEMA.COLUMNS (or equivalent) query and write every char/varchar column's declared width back into columnWidths. They may also write a sentinel (e.g. an empty entry) when the table doesn't exist, so the renderer doesn't keep retrying. Default-empty means "no fallback" — i.e. only widths declared by the same migration plan are considered.
Definition at line 623 of file MigrationPlan.hpp.
| std::set<TableKey> Lightweight::MigrationRenderContext::lookupAttempted |
Tables for which widthLookup has already been called; prevents repeat queries.
Definition at line 635 of file MigrationPlan.hpp.
| std::string Lightweight::MigrationRenderContext::activeMigrationTitle |
Identity of the migration currently being rendered. Set by MigrationManager::ApplySingleMigration before ToSql is called for each step so warnings (e.g. lup-truncate) can attribute themselves to the offending migration. Empty / zero when rendering happens outside a migration run (e.g. unit tests calling ToSql directly).
Definition at line 642 of file MigrationPlan.hpp.
| std::uint64_t Lightweight::MigrationRenderContext::activeMigrationTimestamp = 0 |
Timestamp of the migration currently being rendered (0 outside a migration run).
Definition at line 644 of file MigrationPlan.hpp.