Skip to content

Commit 2fc87d4

Browse files
committed
fix(orm): move QueryBuilder and ScopeChain out of mixin scan path
$integrateComponents("wheels.model") loads every .cfc in vendor/wheels/model/ and mixes their public methods into Model. Having QueryBuilder.cfc and ScopeChain.cfc in that directory caused their methods (where, orWhere, limit, get, first, etc.) to be injected directly onto Model instances where they would fail — variables.whereClauses and other builder state don't exist on the Model. Move both files to vendor/wheels/model/query/ which is not scanned (directoryList recurse=false). Update all `new` references to use the wheels.model.query.* path. Also fix ScopeChain's delegation to QueryBuilder methods — use Invoke() instead of onMissingMethod() so the builder method is called directly. https://claude.ai/code/session_01TYLbmcU97RcvZUDdyUfS1t
1 parent fa0c3ec commit 2fc87d4

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

vendor/wheels/model/onmissingmethod.cfc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ component {
1919
} else {
2020
local.spec = Duplicate(local.scopeDef);
2121
}
22-
local.rv = new wheels.model.ScopeChain(modelReference = this, specs = [local.spec]);
22+
local.rv = new wheels.model.query.ScopeChain(modelReference = this, specs = [local.spec]);
2323
return local.rv;
2424
}
2525

@@ -53,7 +53,7 @@ component {
5353
// --- Chainable Query Builder entry points ---
5454
// Allow calling .where(), .orWhere(), .orderBy() etc. directly on a model to start a query builder chain.
5555
if (ListFindNoCase("where,orWhere,whereNull,whereNotNull,whereBetween,whereIn,whereNotIn,orderBy,limit,offset", arguments.missingMethodName)) {
56-
local.builder = new wheels.model.QueryBuilder(modelReference = this);
56+
local.builder = new wheels.model.query.QueryBuilder(modelReference = this);
5757
// Delegate the call to the query builder
5858
return Invoke(local.builder, arguments.missingMethodName, arguments.missingMethodArguments);
5959
}
File renamed without changes.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,10 @@ component output="false" {
207207
return this;
208208
}
209209

210-
// Check if this is a QueryBuilder method
211-
if (ListFindNoCase("where,orWhere,whereNull,whereNotNull,whereBetween,whereIn,whereNotIn,orderBy,limit,offset,select", arguments.missingMethodName)) {
212-
// Create a query builder from the current state and delegate
210+
// Check if this is a QueryBuilder method — transition from scope chain to query builder
211+
if (ListFindNoCase("where,orWhere,whereNull,whereNotNull,whereBetween,whereIn,whereNotIn,orderBy,limit,offset,select,include,group,distinct", arguments.missingMethodName)) {
213212
local.builder = new QueryBuilder(modelReference = variables.modelReference, scopeSpecs = variables.specs);
214-
return local.builder.onMissingMethod(argumentCollection = arguments);
213+
return Invoke(local.builder, arguments.missingMethodName, arguments.missingMethodArguments);
215214
}
216215

217216
Throw(

0 commit comments

Comments
 (0)