templates: an authored default is escaped into the JavaScript seed it is written into (#7207) - #7255
Open
delchev wants to merge 1 commit into
Open
templates: an authored default is escaped into the JavaScript seed it is written into (#7207)#7255delchev wants to merge 1 commit into
delchev wants to merge 1 commit into
Conversation
… is written into (#7207) `#defaultMeta` interpolated a string default into the JavaScript string literal the item dialog seeds a new line from, so an authored `defaultValue: "Owner's copy"` rendered `def: 'Owner's copy'` and made the whole generated register a syntax error - the page failed to load entirely rather than one field mis-seeding. A backslash and a newline did the same. The seed is now resolved in Java (`JsLiterals.defaultValueExpression`, called from `ModelParameterProcessor` as `dataDefaultValueJsLiteral`), where the backslash, the apostrophe and the control characters that would end the literal are escaped - the JavaScript twin of the Java literal #7154 moved to the same place. It is the only place a Harmonia template seeds a default into a JS literal. The macro's three shapes are unchanged (a checkbox seeds a real boolean, a numeric column a real number, everything else a string - including a DROPDOWN's FK, which stays stringified), so every model that generated before generates byte-identically. Two authoring shapes that used to emit broken JavaScript now seed what the column holds and the repository applies: an SQL-quoted string default (`'DRAFT'`, which rendered `def: ''DRAFT''`), and a boolean written `TRUE` or `1`, which seeded false next to a DB DEFAULT of true. A numeric default that is not a number falls back to a string rather than a bare identifier the register would choke on. The key is present only on a property that has a default to seed, so the shapes live in one place instead of being restated in the template's `#if`, and the macro reads the key's presence. `AuthoredDefaults` holds the two readings of the authored text both literal writers share. Fixes #7207 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
delchev
force-pushed
the
issue-7207-js-default-literal
branch
from
September 9, 2026 18:18
a777ecf to
f90938e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#defaultMetaindetail-register.js.templateinterpolated a string default into the JavaScript string literal the item dialog seeds a new line from, so an authoreddefaultValue: "Owner's copy"rendereddef: 'Owner's copy'and made the whole generated register a syntax error - the page failed to load entirely, rather than one field mis-seeding. A backslash and a newline did the same.The seed is now resolved in Java (
JsLiterals.defaultValueExpression, called fromModelParameterProcessorasdataDefaultValueJsLiteral), where the backslash, the apostrophe and the control characters that would end the literal are escaped - the JavaScript twin of the Java literal #7154 moved to the same place. Grepping the Harmonia templates confirms this macro is the only place a default is seeded into a JS literal.The macro's three shapes are unchanged (a checkbox seeds a real boolean, a numeric column a real number, everything else a string - including a DROPDOWN's FK, which stays stringified), so every model that generated before generates byte-identically. Two authoring shapes that used to emit broken JavaScript now seed what the column holds and the repository applies: an SQL-quoted string default (
'DRAFT', which rendereddef: ''DRAFT''), and a boolean writtenTRUEor1, which seeded false next to a DB DEFAULT of true. A numeric default that is not a number falls back to a string rather than a bare identifier the register would choke on.AuthoredDefaultsholds the two readings of the authored text (the SQL quotes, the boolean shapes) that both literal writers share.Verified:
JsLiteralsTest+ModelParameterProcessorTest(125 tests inide-template, green) andIntentEngineIT#an_authored_default_is_escaped_into_the_item_dialog_seed, which generates the Harmonia UI for a composition child whose defaults carry an apostrophe and a backslash and asserts the emitted seeds - run alongside the two neighbouring default/harmonia ITs, 3/3 green.Fixes #7207
🤖 Generated with Claude Code