Commit 6c675b0
fix: PR #4039 F2-1 follow-up — PG lowercase-then-quote across DDL/DML/detection
Closes the F2-1 reviewer comment "the SQLite / MySQL / PG V1 baselines deserve
the same scan" properly for PG, which F2 had deferred as a chain-wide limitation.
PG case-folds unquoted identifiers to lowercase at parse time, so reserved-keyword
table names (Order, User, Group, …) failed under the legacy unquoted DDL chain.
This commit makes the PG path quote-safe end-to-end while preserving backward
compatibility with existing folded tables.
Approach: lowercase the configured identifier first (matching PG's natural fold
of the legacy unquoted form), then double-quote at every emission site. A new
`PgIdentifier` helper centralizes this in the shared PG assembly.
DDL emitters (Wave A)
- PostgreSqlOutboxBuilder.GetDDL/GetExistsQuery and PostgreSqlInboxBuilder
GetDDL/GetExistsQuery now emit `"schema"."table"` via PgIdentifier.
- PostgreSqlOutboxMigrationCatalog V1 historical DDL + V2..V7 ALTERs and
PostgreSqlInboxMigrationCatalog V1 historical DDL apply the same convention.
Detection / validator / lock / history (Wave B)
- PostgreSqlBoxDetectionHelper user-table lookups (information_schema.tables,
information_schema.columns, history-row params) PgIdentifier.Normalize the
configured values so mixed-case defaults (e.g. "Outbox") match PG's stored
folded form. This also closes a latent bug: pre-change detection passed the
mixed-case configured name verbatim and would have missed `outbox` for any
user on the framework default — only undetectable because tests use lowercase
/ GUID names exclusively.
- PostgreSqlBoxDetectionHelper.DoesHistoryExistAsync inlines the literal
`__BrighterMigrationHistory` existence check so it bypasses the fold path —
the system-table CREATE quotes the name and pg_class case-preserves it.
- PostgreSqlPayloadModeValidator normalizes its parameter values.
- PostgreSqlBoxMigrationRunner stores history rows under lowercase
BoxTableName/SchemaName and hashes the advisory-lock key off the
PG-normalized lock resource string.
Runtime DML (Wave C)
- RelationalDatabaseInbox.GenerateSqlText lifted from private to protected
virtual to match the existing Outbox shape.
- PostgreSqlOutbox + PostgreSqlInbox override GenerateSqlText to lowercase-quote
the configured table name before string.Format substitutes into the SQL
templates — closes the runtime path for reserved-keyword names.
Tests + docs (Wave D)
- New end-to-end test pins the contract by configuring `OutBoxTableName = "Order"`
(PG reserved keyword): asserts fresh install succeeds against the folded
`order` table, history is keyed under lowercase, chain replay is a no-op,
and PostgreSqlOutbox AddAsync/GetAsync round-trips a message through the
reserved-keyword table.
- Full PG suite (182 tests) passes.
- docs/guides/box-provisioning-new-backend.md "Operational notes" section
documents the PG fold-then-quote convention and the upgrade-safety story
for existing deployments (history rows with mixed-case BoxTableName values
become unreachable on read, but the ALTER chain is idempotent so the worst
case is one no-op re-run).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent e040c7a commit 6c675b0
13 files changed
Lines changed: 335 additions & 55 deletions
File tree
- docs/guides
- src
- Paramore.Brighter.BoxProvisioning.PostgreSql
- Paramore.Brighter.Inbox.Postgres
- Paramore.Brighter.Outbox.PostgreSql
- Paramore.Brighter.PostgreSql
- Paramore.Brighter
- tests/Paramore.Brighter.PostgresSQL.Tests/BoxProvisioning
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
270 | 276 | | |
271 | 277 | | |
272 | 278 | | |
| |||
Lines changed: 33 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
84 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
85 | 92 | | |
86 | 93 | | |
87 | 94 | | |
| |||
103 | 110 | | |
104 | 111 | | |
105 | 112 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
110 | 128 | | |
111 | 129 | | |
112 | 130 | | |
113 | 131 | | |
114 | 132 | | |
115 | 133 | | |
116 | | - | |
117 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
118 | 139 | | |
119 | 140 | | |
120 | 141 | | |
| |||
160 | 181 | | |
161 | 182 | | |
162 | 183 | | |
163 | | - | |
164 | | - | |
| 184 | + | |
| 185 | + | |
165 | 186 | | |
166 | 187 | | |
167 | 188 | | |
| |||
242 | 263 | | |
243 | 264 | | |
244 | 265 | | |
245 | | - | |
246 | | - | |
| 266 | + | |
| 267 | + | |
247 | 268 | | |
248 | 269 | | |
249 | 270 | | |
| |||
Lines changed: 14 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
108 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
109 | 112 | | |
110 | | - | |
| 113 | + | |
| 114 | + | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
| |||
290 | 294 | | |
291 | 295 | | |
292 | 296 | | |
293 | | - | |
294 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
295 | 305 | | |
296 | 306 | | |
297 | 307 | | |
| |||
Lines changed: 8 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
117 | | - | |
| 118 | + | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| |||
Lines changed: 15 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
| |||
137 | 139 | | |
138 | 140 | | |
139 | 141 | | |
140 | | - | |
| 142 | + | |
141 | 143 | | |
142 | 144 | | |
143 | 145 | | |
| |||
215 | 217 | | |
216 | 218 | | |
217 | 219 | | |
218 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
219 | 225 | | |
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | | - | |
64 | | - | |
65 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
66 | 78 | | |
0 commit comments