Skip to content

Commit 2d65639

Browse files
committed
fix(orm): use equals-style structs and fully qualified component paths
Replace JSON-style struct literals ({key: value}) with CFML-standard equals-style ({key = value}) for consistency with the rest of the codebase and reliable cross-engine compatibility. Replace relative `new ScopeChain()` / `new QueryBuilder()` cross- references with fully qualified `new wheels.model.query.ScopeChain()` paths. Lucee resolves relative paths from the webroot, not the component directory, causing component-not-found errors. Also replace ternary operator in findEach() with an explicit if/else for Adobe ColdFusion 2018 compatibility. https://claude.ai/code/session_01TYLbmcU97RcvZUDdyUfS1t
1 parent 2fc87d4 commit 2d65639

File tree

4 files changed

+38
-36
lines changed

4 files changed

+38
-36
lines changed

vendor/wheels/model/properties.cfc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,9 +767,9 @@ component {
767767
}
768768
for (local.name in ListToArray(local.enumDef.names)) {
769769
local.storedValue = local.enumDef.values[local.name];
770-
variables.wheels.class.scopes[local.name] = {
771-
where: "#arguments.property# = '#local.storedValue#'"
772-
};
770+
local.scopeDef = {};
771+
local.scopeDef.where = "#arguments.property# = '#local.storedValue#'";
772+
variables.wheels.class.scopes[local.name] = local.scopeDef;
773773
}
774774
}
775775
}

vendor/wheels/model/query/QueryBuilder.cfc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ component output="false" {
4848
public any function where() {
4949
if (StructCount(arguments) == 1) {
5050
// Raw WHERE string: .where("status = 'active'")
51-
ArrayAppend(variables.whereClauses, {type: "AND", clause: arguments[1]});
51+
ArrayAppend(variables.whereClauses, {type = "AND", clause = arguments[1]});
5252
} else if (StructCount(arguments) == 2) {
5353
// Property + value: .where("status", "active") -> status = 'active'
5454
local.clause = $buildCondition(arguments[1], "=", arguments[2]);
55-
ArrayAppend(variables.whereClauses, {type: "AND", clause: local.clause});
55+
ArrayAppend(variables.whereClauses, {type = "AND", clause = local.clause});
5656
} else if (StructCount(arguments) == 3) {
5757
// Property + operator + value: .where("age", ">", 18) -> age > 18
5858
local.clause = $buildCondition(arguments[1], arguments[2], arguments[3]);
59-
ArrayAppend(variables.whereClauses, {type: "AND", clause: local.clause});
59+
ArrayAppend(variables.whereClauses, {type = "AND", clause = local.clause});
6060
}
6161
return this;
6262
}
@@ -66,13 +66,13 @@ component output="false" {
6666
*/
6767
public any function orWhere() {
6868
if (StructCount(arguments) == 1) {
69-
ArrayAppend(variables.whereClauses, {type: "OR", clause: arguments[1]});
69+
ArrayAppend(variables.whereClauses, {type = "OR", clause = arguments[1]});
7070
} else if (StructCount(arguments) == 2) {
7171
local.clause = $buildCondition(arguments[1], "=", arguments[2]);
72-
ArrayAppend(variables.whereClauses, {type: "OR", clause: local.clause});
72+
ArrayAppend(variables.whereClauses, {type = "OR", clause = local.clause});
7373
} else if (StructCount(arguments) == 3) {
7474
local.clause = $buildCondition(arguments[1], arguments[2], arguments[3]);
75-
ArrayAppend(variables.whereClauses, {type: "OR", clause: local.clause});
75+
ArrayAppend(variables.whereClauses, {type = "OR", clause = local.clause});
7676
}
7777
return this;
7878
}
@@ -83,7 +83,7 @@ component output="false" {
8383
* @property The property name to check for NULL.
8484
*/
8585
public any function whereNull(required string property) {
86-
ArrayAppend(variables.whereClauses, {type: "AND", clause: "#arguments.property# IS NULL"});
86+
ArrayAppend(variables.whereClauses, {type = "AND", clause = "#arguments.property# IS NULL"});
8787
return this;
8888
}
8989

@@ -93,7 +93,7 @@ component output="false" {
9393
* @property The property name to check for NOT NULL.
9494
*/
9595
public any function whereNotNull(required string property) {
96-
ArrayAppend(variables.whereClauses, {type: "AND", clause: "#arguments.property# IS NOT NULL"});
96+
ArrayAppend(variables.whereClauses, {type = "AND", clause = "#arguments.property# IS NOT NULL"});
9797
return this;
9898
}
9999

@@ -107,7 +107,7 @@ component output="false" {
107107
public any function whereBetween(required string property, required any low, required any high) {
108108
local.lowQuoted = $quoteValue(arguments.property, arguments.low);
109109
local.highQuoted = $quoteValue(arguments.property, arguments.high);
110-
ArrayAppend(variables.whereClauses, {type: "AND", clause: "#arguments.property# BETWEEN #local.lowQuoted# AND #local.highQuoted#"});
110+
ArrayAppend(variables.whereClauses, {type = "AND", clause = "#arguments.property# BETWEEN #local.lowQuoted# AND #local.highQuoted#"});
111111
return this;
112112
}
113113

@@ -119,7 +119,7 @@ component output="false" {
119119
*/
120120
public any function whereIn(required string property, required any values) {
121121
local.valueList = $quoteValueList(arguments.property, arguments.values);
122-
ArrayAppend(variables.whereClauses, {type: "AND", clause: "#arguments.property# IN (#local.valueList#)"});
122+
ArrayAppend(variables.whereClauses, {type = "AND", clause = "#arguments.property# IN (#local.valueList#)"});
123123
return this;
124124
}
125125

@@ -131,7 +131,7 @@ component output="false" {
131131
*/
132132
public any function whereNotIn(required string property, required any values) {
133133
local.valueList = $quoteValueList(arguments.property, arguments.values);
134-
ArrayAppend(variables.whereClauses, {type: "AND", clause: "#arguments.property# NOT IN (#local.valueList#)"});
134+
ArrayAppend(variables.whereClauses, {type = "AND", clause = "#arguments.property# NOT IN (#local.valueList#)"});
135135
return this;
136136
}
137137

@@ -212,7 +212,7 @@ component output="false" {
212212

213213
// Start with scope specs if present
214214
if (ArrayLen(variables.scopeSpecs)) {
215-
local.scopeChain = new ScopeChain(modelReference = variables.modelReference, specs = variables.scopeSpecs);
215+
local.scopeChain = new wheels.model.query.ScopeChain(modelReference = variables.modelReference, specs = variables.scopeSpecs);
216216
local.args = local.scopeChain.$mergeSpecs();
217217
}
218218

vendor/wheels/model/query/ScopeChain.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ component output="false" {
209209

210210
// Check if this is a QueryBuilder method — transition from scope chain to query builder
211211
if (ListFindNoCase("where,orWhere,whereNull,whereNotNull,whereBetween,whereIn,whereNotIn,orderBy,limit,offset,select,include,group,distinct", arguments.missingMethodName)) {
212-
local.builder = new QueryBuilder(modelReference = variables.modelReference, scopeSpecs = variables.specs);
212+
local.builder = new wheels.model.query.QueryBuilder(modelReference = variables.modelReference, scopeSpecs = variables.specs);
213213
return Invoke(local.builder, arguments.missingMethodName, arguments.missingMethodArguments);
214214
}
215215

vendor/wheels/model/read.cfc

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -644,16 +644,19 @@ component {
644644
local.keepGoing = true;
645645

646646
while (local.keepGoing) {
647-
local.finderArgs = {
648-
where: arguments.where,
649-
order: arguments.order,
650-
include: arguments.include,
651-
select: arguments.select,
652-
page: local.page,
653-
perPage: arguments.batchSize,
654-
returnAs: arguments.returnAs == "struct" ? "structs" : "objects",
655-
includeSoftDeletes: arguments.includeSoftDeletes
656-
};
647+
local.finderArgs = {};
648+
local.finderArgs.where = arguments.where;
649+
local.finderArgs.order = arguments.order;
650+
local.finderArgs.include = arguments.include;
651+
local.finderArgs.select = arguments.select;
652+
local.finderArgs.page = local.page;
653+
local.finderArgs.perPage = arguments.batchSize;
654+
local.finderArgs.includeSoftDeletes = arguments.includeSoftDeletes;
655+
if (arguments.returnAs == "struct") {
656+
local.finderArgs.returnAs = "structs";
657+
} else {
658+
local.finderArgs.returnAs = "objects";
659+
}
657660
if (StructKeyExists(arguments, "parameterize")) {
658661
local.finderArgs.parameterize = arguments.parameterize;
659662
}
@@ -712,16 +715,15 @@ component {
712715
local.keepGoing = true;
713716

714717
while (local.keepGoing) {
715-
local.finderArgs = {
716-
where: arguments.where,
717-
order: arguments.order,
718-
include: arguments.include,
719-
select: arguments.select,
720-
page: local.page,
721-
perPage: arguments.batchSize,
722-
returnAs: arguments.returnAs,
723-
includeSoftDeletes: arguments.includeSoftDeletes
724-
};
718+
local.finderArgs = {};
719+
local.finderArgs.where = arguments.where;
720+
local.finderArgs.order = arguments.order;
721+
local.finderArgs.include = arguments.include;
722+
local.finderArgs.select = arguments.select;
723+
local.finderArgs.page = local.page;
724+
local.finderArgs.perPage = arguments.batchSize;
725+
local.finderArgs.returnAs = arguments.returnAs;
726+
local.finderArgs.includeSoftDeletes = arguments.includeSoftDeletes;
725727
if (StructKeyExists(arguments, "parameterize")) {
726728
local.finderArgs.parameterize = arguments.parameterize;
727729
}

0 commit comments

Comments
 (0)