Skip to content

Commit 2c7640c

Browse files
akoclaude
andcommitted
fix: repair remaining lowercase convention regressions
More ToUpper-with-lowercase-cases bugs and hardcoded uppercase strings: - Workflow properties: visitor hardcoded "DISPLAY", "EXPORT_LEVEL" etc. but mutator case values were already lowercase. Normalized all property strings (both hardcoded in visitor and remaining uppercase cases in mutator) to lowercase. Updated tests accordingly. - Settings executor: strings.ToUpper(stmt.Section) with lowercase case values. Changed to ToLower; fixed "LANGUAGE" case and hardcoded "CONSTANT"/ "CONFIGURATION" in visitor. Fixed MDL example (alter settings LANGUAGE). - Entity event handlers: describe output used ToUpper for moment/event name. Changed to ToLower so output is "on before commit" not "on BEFORE COMMIT". - REST client: method stored as BSON title case ("Get"), describe output needs strings.ToLower to produce "get" not "Get". - Design properties: ON/OFF toggle values hardcoded as "ON"/"OFF" in visitor but switch used ToUpper with lowercase "on"/"off" cases. Fixed visitor to produce lowercase and switch to use ToLower. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9b76c07 commit 2c7640c

12 files changed

Lines changed: 47 additions & 52 deletions

mdl-examples/doctype-tests/14-project-settings-examples.mdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ drop configuration 'Staging';
124124
/**
125125
* Example 4.1: Set default language
126126
*/
127-
alter settings LANGUAGE DefaultLanguageCode = 'en_US';
127+
alter settings language DefaultLanguageCode = 'en_US';
128128

129129
/**
130130
* Example 4.2: Configure workflow settings

mdl/backend/mpr/workflow_mutator.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ func (m *mprWorkflowMutator) SetProperty(prop string, value string) error {
8585
}
8686
return nil
8787

88-
case "EXPORT_LEVEL":
88+
case "export_level":
8989
dSet(m.rawData, "ExportLevel", value)
9090
return nil
9191

92-
case "DUE_DATE":
92+
case "due_date":
9393
dSet(m.rawData, "DueDate", value)
9494
return nil
9595

@@ -100,7 +100,7 @@ func (m *mprWorkflowMutator) SetProperty(prop string, value string) error {
100100

101101
func (m *mprWorkflowMutator) SetPropertyWithEntity(prop string, value string, entity string) error {
102102
switch prop {
103-
case "OVERVIEW_PAGE":
103+
case "overview_page":
104104
if value == "" {
105105
dSet(m.rawData, "AdminPage", nil)
106106
} else {
@@ -180,7 +180,7 @@ func (m *mprWorkflowMutator) SetActivityProperty(activityRef string, atPos int,
180180
}
181181
return nil
182182

183-
case "TARGETING_MICROFLOW":
183+
case "targeting_microflow":
184184
userTargeting := bson.D{
185185
{Key: "$ID", Value: bsonutil.NewIDBsonBinary()},
186186
{Key: "$Type", Value: "Workflows$MicroflowUserTargeting"},
@@ -189,7 +189,7 @@ func (m *mprWorkflowMutator) SetActivityProperty(activityRef string, atPos int,
189189
dSet(actDoc, "UserTargeting", userTargeting)
190190
return nil
191191

192-
case "TARGETING_XPATH":
192+
case "targeting_xpath":
193193
userTargeting := bson.D{
194194
{Key: "$ID", Value: bsonutil.NewIDBsonBinary()},
195195
{Key: "$Type", Value: "Workflows$XPathUserTargeting"},
@@ -198,7 +198,7 @@ func (m *mprWorkflowMutator) SetActivityProperty(activityRef string, atPos int,
198198
dSet(actDoc, "UserTargeting", userTargeting)
199199
return nil
200200

201-
case "DUE_DATE":
201+
case "due_date":
202202
dSet(actDoc, "DueDate", value)
203203
return nil
204204

mdl/backend/mpr/workflow_mutator_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func TestWorkflowMutator_SetProperty_ExportLevel(t *testing.T) {
183183
doc = append(doc, bson.E{Key: "ExportLevel", Value: "Usable"})
184184
m := newMutator(doc)
185185

186-
if err := m.SetProperty("EXPORT_LEVEL", "Hidden"); err != nil {
186+
if err := m.SetProperty("export_level", "Hidden"); err != nil {
187187
t.Fatalf("SetProperty EXPORT_LEVEL failed: %v", err)
188188
}
189189
if got := dGetString(m.rawData, "ExportLevel"); got != "Hidden" {
@@ -436,7 +436,7 @@ func TestWorkflowMutator_SetActivityProperty_DueDate(t *testing.T) {
436436
act = append(act, bson.E{Key: "DueDate", Value: ""})
437437
m := newMutator(makeWorkflowDoc(act))
438438

439-
if err := m.SetActivityProperty("Review", 0, "DUE_DATE", "${PT48H}"); err != nil {
439+
if err := m.SetActivityProperty("Review", 0, "due_date", "${PT48H}"); err != nil {
440440
t.Fatalf("SetActivityProperty DUE_DATE failed: %v", err)
441441
}
442442

@@ -1220,7 +1220,7 @@ func TestWorkflowMutator_SetActivityProperty_TargetingMicroflow(t *testing.T) {
12201220
act = append(act, bson.E{Key: "UserTargeting", Value: nil})
12211221
m := newMutator(makeWorkflowDoc(act))
12221222

1223-
if err := m.SetActivityProperty("Review", 0, "TARGETING_MICROFLOW", "MyModule.AssignReviewer"); err != nil {
1223+
if err := m.SetActivityProperty("Review", 0, "targeting_microflow", "MyModule.AssignReviewer"); err != nil {
12241224
t.Fatalf("SetActivityProperty TARGETING_MICROFLOW failed: %v", err)
12251225
}
12261226

@@ -1242,7 +1242,7 @@ func TestWorkflowMutator_SetActivityProperty_TargetingXPath(t *testing.T) {
12421242
act = append(act, bson.E{Key: "UserTargeting", Value: nil})
12431243
m := newMutator(makeWorkflowDoc(act))
12441244

1245-
if err := m.SetActivityProperty("Review", 0, "TARGETING_XPATH", "[Role = 'Admin']"); err != nil {
1245+
if err := m.SetActivityProperty("Review", 0, "targeting_xpath", "[Role = 'Admin']"); err != nil {
12461246
t.Fatalf("SetActivityProperty TARGETING_XPATH failed: %v", err)
12471247
}
12481248

@@ -1265,7 +1265,7 @@ func TestWorkflowMutator_SetPropertyWithEntity_OverviewPage(t *testing.T) {
12651265
doc = append(doc, bson.E{Key: "AdminPage", Value: nil})
12661266
m := newMutator(doc)
12671267

1268-
if err := m.SetPropertyWithEntity("OVERVIEW_PAGE", "MyModule.OverviewPage", ""); err != nil {
1268+
if err := m.SetPropertyWithEntity("overview_page", "MyModule.OverviewPage", ""); err != nil {
12691269
t.Fatalf("SetPropertyWithEntity OVERVIEW_PAGE failed: %v", err)
12701270
}
12711271

@@ -1285,7 +1285,7 @@ func TestWorkflowMutator_SetPropertyWithEntity_OverviewPage_Clear(t *testing.T)
12851285
}})
12861286
m := newMutator(doc)
12871287

1288-
if err := m.SetPropertyWithEntity("OVERVIEW_PAGE", "", ""); err != nil {
1288+
if err := m.SetPropertyWithEntity("overview_page", "", ""); err != nil {
12891289
t.Fatalf("SetPropertyWithEntity clear failed: %v", err)
12901290
}
12911291

mdl/executor/cmd_entities_describe.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,7 @@ func describeEntity(ctx *ExecContext, name ast.QualifiedName) error {
402402
if mfName == "" {
403403
continue
404404
}
405-
eventName := string(eh.Event)
406-
if eventName == "RollBack" {
407-
eventName = "rollback"
408-
} else {
409-
eventName = strings.ToUpper(eventName)
410-
}
405+
eventName := strings.ToLower(string(eh.Event))
411406
// Show parameter: ($currentObject) or ()
412407
paramStr := "()"
413408
if eh.PassEventObject {
@@ -419,7 +414,7 @@ func describeEntity(ctx *ExecContext, name ast.QualifiedName) error {
419414
options = " raise error"
420415
}
421416
fmt.Fprintf(ctx.Output, "\non %s %s call %s%s%s",
422-
strings.ToUpper(string(eh.Moment)), eventName, mfName, paramStr, options)
417+
strings.ToLower(string(eh.Moment)), eventName, mfName, paramStr, options)
423418
}
424419

425420
fmt.Fprintln(ctx.Output, ";")

mdl/executor/cmd_pages_builder_v3.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ func applyWidgetAppearance(widget pages.Widget, w *ast.WidgetV3, theme *ThemeReg
419419
if len(astProps) > 0 {
420420
var dpValues []pages.DesignPropertyValue
421421
for _, p := range astProps {
422-
switch strings.ToUpper(p.Value) {
422+
switch strings.ToLower(p.Value) {
423423
case "on":
424424
dpValues = append(dpValues, pages.DesignPropertyValue{
425425
Key: p.Key,

mdl/executor/cmd_rest_clients.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func outputRestOperation(w io.Writer, op *model.RestClientOperation) {
146146
}
147147

148148
fmt.Fprintf(w, " operation %s {\n", op.Name)
149-
fmt.Fprintf(w, " Method: %s,\n", op.HttpMethod)
149+
fmt.Fprintf(w, " Method: %s,\n", strings.ToLower(op.HttpMethod))
150150
fmt.Fprintf(w, " Path: '%s',\n", op.Path)
151151

152152
// Parameters: ($var: Type, ...)

mdl/executor/cmd_settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func alterSettings(ctx *ExecContext, stmt *ast.AlterSettingsStmt) error {
178178
return mdlerrors.NewBackend("read project settings", err)
179179
}
180180

181-
section := strings.ToUpper(stmt.Section)
181+
section := strings.ToLower(stmt.Section)
182182
switch section {
183183
case "model":
184184
if ps.Model == nil {

mdl/visitor/visitor_page_v3.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,10 +1088,10 @@ func buildDesignPropertyEntryV3(ctx parser.IDesignPropertyEntryV3Context) *ast.D
10881088

10891089
// Value: second STRING_LITERAL, ON, or OFF
10901090
if entryCtx.ON() != nil {
1091-
return &ast.DesignPropertyEntryV3{Key: key, Value: "ON"}
1091+
return &ast.DesignPropertyEntryV3{Key: key, Value: "on"}
10921092
}
10931093
if entryCtx.OFF() != nil {
1094-
return &ast.DesignPropertyEntryV3{Key: key, Value: "OFF"}
1094+
return &ast.DesignPropertyEntryV3{Key: key, Value: "off"}
10951095
}
10961096
if len(allStrings) >= 2 {
10971097
return &ast.DesignPropertyEntryV3{Key: key, Value: unquoteString(allStrings[1].GetText())}

mdl/visitor/visitor_rest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func parseRestClientOpProp(ctx *parser.RestClientOpPropContext, op *ast.RestOper
139139

140140
// Method: GET
141141
if mCtx := ctx.RestHttpMethod(); mCtx != nil {
142-
op.Method = strings.ToUpper(mCtx.GetText())
142+
op.Method = strings.ToLower(mCtx.GetText())
143143
return
144144
}
145145

mdl/visitor/visitor_settings.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func (b *Builder) ExitAlterSettingsClause(ctx *parser.AlterSettingsClauseContext
1717

1818
if ctx.DROP() != nil && ctx.CONSTANT() != nil {
1919
// ALTER SETTINGS DROP CONSTANT 'name' [IN CONFIGURATION 'cfg']
20-
stmt.Section = "CONSTANT"
20+
stmt.Section = "constant"
2121
stmt.DropConstant = true
2222
allStrings := ctx.AllSTRING_LITERAL()
2323
if len(allStrings) > 0 {
@@ -28,7 +28,7 @@ func (b *Builder) ExitAlterSettingsClause(ctx *parser.AlterSettingsClauseContext
2828
}
2929
} else if ctx.CONSTANT() != nil {
3030
// ALTER SETTINGS CONSTANT 'name' (VALUE 'value' | DROP) [IN CONFIGURATION 'cfg']
31-
stmt.Section = "CONSTANT"
31+
stmt.Section = "constant"
3232
allStrings := ctx.AllSTRING_LITERAL()
3333
if len(allStrings) > 0 {
3434
stmt.ConstantId = unquoteString(allStrings[0].GetText())
@@ -44,7 +44,7 @@ func (b *Builder) ExitAlterSettingsClause(ctx *parser.AlterSettingsClauseContext
4444
}
4545
} else if ctx.CONFIGURATION() != nil {
4646
// ALTER SETTINGS CONFIGURATION 'name' Key = Value, ...
47-
stmt.Section = "CONFIGURATION"
47+
stmt.Section = "configuration"
4848
allStrings := ctx.AllSTRING_LITERAL()
4949
if len(allStrings) > 0 {
5050
stmt.ConfigName = unquoteString(allStrings[0].GetText())

0 commit comments

Comments
 (0)