Skip to content

Commit 0d199a8

Browse files
authored
Merge pull request #1327 from chapmandu/issue-1319-model-datasource-bug
issue #1319 model datasource bug
2 parents 8f649ea + 7b2898b commit 0d199a8

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

box.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"CFWheels",
3-
"version":"2.5.0",
3+
"version":"2.5.1",
44
"author":"CFWheels Core Team and Community",
55
"shortDescription":"CFWheels MVC Framework Core Directory",
66
"location":"ForgeboxStorage",

wheels/model/read.cfm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public any function findAll(
4747
boolean callbacks = "true",
4848
boolean includeSoftDeletes = "false",
4949
struct useIndex = {},
50-
string dataSource = application.wheels.dataSourceName,
50+
string dataSource = variables.wheels.class.dataSource,
5151
numeric $limit = "0",
5252
numeric $offset = "0"
5353
) {
@@ -396,7 +396,7 @@ public any function findByKey(
396396
string returnAs,
397397
boolean callbacks = "true",
398398
boolean includeSoftDeletes = "false",
399-
string dataSource = application.wheels.dataSourceName
399+
string dataSource = variables.wheels.class.dataSource
400400
) {
401401
$args(name = "findByKey", args = arguments);
402402
$setDebugName(name = "FindByKey", args = arguments);
@@ -445,7 +445,7 @@ public any function findOne(
445445
string returnAs,
446446
boolean includeSoftDeletes = "false",
447447
struct useIndex = {},
448-
string dataSource = application.wheels.dataSourceName
448+
string dataSource = variables.wheels.class.dataSource
449449
) {
450450
$args(name = "findOne", args = arguments);
451451
$setDebugName(name = "findOne", args = arguments);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
component extends="Model" {
2+
3+
function config() {
4+
table("authors");
5+
dataSource("wheelstestdb_h2");
6+
}
7+
8+
}

wheels/tests/model/read/datasource.cfc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ component extends="wheels.tests.Test" {
3434
finderArgs = {where = "firstName = '#firstName#'", datasource = altDatasource};
3535
}
3636

37+
function test_findall_respects_model_config_datasource() {
38+
if (!isTestable) return;
39+
transaction {
40+
this.db_setup();
41+
// ensure this is using the wheelstestdb_h2 as defined in the model config
42+
actual = model("AuthorAlternateDatasource").findAll(where = "firstName = '#firstName#'");
43+
TransactionRollback();
44+
}
45+
assert("actual.recordCount");
46+
}
47+
3748
function test_findall_with_datasource_argument() {
3849
if (!isTestable) return;
3950
transaction {

0 commit comments

Comments
 (0)