[OPENJPA-2971] Make PostgreSQL StoreCharsAsNumbers default overridable and release-note it - #163
[OPENJPA-2971] Make PostgreSQL StoreCharsAsNumbers default overridable and release-note it#163rzo1 wants to merge 1 commit into
Conversation
Since #144 PostgresDictionary.connectedConfiguration() unconditionally set storeCharsAsNumbers=false on PostgreSQL 9+, clobbering an explicit StoreCharsAsNumbers=true from the DBDictionary plugin properties (which are applied before connectedConfiguration()). Track explicit user values via a new setStoreCharsAsNumbers() setter, make native CHAR storage the PostgresDictionary default and only fall back to numeric storage on PostgreSQL < 9 when not configured explicitly. Document the new default and the opt-out in the reference guide and migration considerations; add TestPostgresDictionary. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJiFSo4QfgPaz7i5UQPREw
| public boolean storeCharsAsNumbers = true; | ||
| // true once the user explicitly configured StoreCharsAsNumbers; dictionaries | ||
| // must not auto-detect over such a value (OPENJPA-2971) | ||
| private boolean storeCharsAsNumbersExplicit = false; |
There was a problem hiding this comment.
Hello @rzo1,
I need some clarifications on this one :)
storeCharsAsNumbersExplicit, getStoreCharsAsNumbers and setStoreCharsAsNumbers seems to be not used in the code
why do we need them?
There was a problem hiding this comment.
storeCharsAsNumbersExplicit is used, just not directly:
- written in setStoreCharsAsNumbers (DBDictionary.java:6052)
- read by isStoreCharsAsNumbersExplicit() (DBDictionary.java:6062)
- which is called from PostgresDictionary.connectedConfiguration (PostgresDictionary.java:1073): if (maj < 9 && !isStoreCharsAsNumbersExplicit())
Same for the setter: it looks unused because nothing calls it by name, but Options.matchOptionToMember resolves a plugin property to a setter method first and only falls back to the public field, so postgres(StoreCharsAsNumbers=true) goes through it.
(the getter is unused but there for consistency)
There was a problem hiding this comment.
It was added to preserve backward compat (as requested by Romain) as backward compat flag for users who have schemas sitting in (upgraded) Postgres databases
There was a problem hiding this comment.
My bad, need more coffee this morning :)
Sorry for the noise :)
Since #144
PostgresDictionary.connectedConfiguration()unconditionally setstoreCharsAsNumbers=falseon PostgreSQL 9+. BecauseDBDictionaryFactoryapplies the user'sDBDictionaryplugin properties beforeconnectedConfiguration(), an explicitStoreCharsAsNumbers=truewas silently clobbered, breaking schemas created by earlier OpenJPA releases (char fields inINTEGERcolumns).This adds
setStoreCharsAsNumbers()/getStoreCharsAsNumbers()toDBDictionary(Optionsprefers the setter over the public field) to track an explicit user value, makes native CHAR storage thePostgresDictionaryconstructor default, and only falls back to numeric storage on PostgreSQL < 9 when nothing was configured explicitly. The public field is kept for backward compatibility.Documents the new default and the opt-out (
openjpa.jdbc.DBDictionary=postgres(StoreCharsAsNumbers=true)) in the reference guide and the JPA 3.2 migration considerations, and addsTestPostgresDictionarycovering defaults, explicit overrides via plugin properties / setter / field, andDBDictionaryFactoryend-to-end. The TCK-relevant default (CHAR columns) is unchanged.Ref: #144 (comment)