Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
1b4a9b62
Commit
1b4a9b62
authored
Jun 25, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #3568: When the primary query sets `asArray`, it is not respected by the…
Fixes #3568: When the primary query sets `asArray`, it is not respected by the `via` relational query
parent
7c2be495
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
1 deletion
+10
-1
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
ActiveRelationTrait.php
framework/db/ActiveRelationTrait.php
+5
-1
ActiveRecordTest.php
tests/unit/framework/db/ActiveRecordTest.php
+4
-0
No files found.
framework/CHANGELOG.md
View file @
1b4a9b62
...
...
@@ -39,6 +39,7 @@ Yii Framework 2 Change Log
-
Bug #3559: Use native support for batchInsert in SQLite versions >= 3.7.11 and avoid limitations of the fallback (cebe)
-
Bug #3564: Fixed the bug that primary key columns should not take default values from schema (qiangxue)
-
Bug #3567: Fixed the bug that smallint was treated as string for PostgreSQL (qiangxue)
-
Bug #3568: When the primary query sets
`asArray`
, it is not respected by the
`via`
relational query (qiangxue)
-
Bug #3578: Fixed postgreSQL column type detection, added missing types (MDMunir, cebe)
-
Bug #3583: Added typecast to auto value of primary key on insert of sql active record (cebe)
-
Bug #3591: Fixed incomplete obsolete filling in i18n
`MessageController::saveMessagesToDb()`
(advsm)
...
...
framework/db/ActiveRelationTrait.php
View file @
1b4a9b62
...
...
@@ -203,8 +203,12 @@ trait ActiveRelationTrait
$this
->
filterByModels
(
$viaModels
);
}
elseif
(
is_array
(
$this
->
via
))
{
// via relation
/* @var $viaQuery ActiveRelationTrait */
/* @var $viaQuery ActiveRelationTrait
|ActiveQueryTrait
*/
list
(
$viaName
,
$viaQuery
)
=
$this
->
via
;
if
(
$viaQuery
->
asArray
===
null
)
{
// inherit asArray from primary query
$viaQuery
->
asArray
(
$this
->
asArray
);
}
$viaQuery
->
primaryModel
=
null
;
$viaModels
=
$viaQuery
->
populateRelation
(
$viaName
,
$primaryModels
);
$this
->
filterByModels
(
$viaModels
);
...
...
tests/unit/framework/db/ActiveRecordTest.php
View file @
1b4a9b62
...
...
@@ -121,6 +121,9 @@ class ActiveRecordTest extends DatabaseTestCase
$order
=
Order
::
findOne
(
2
);
$this
->
assertEquals
(
2
,
$order
->
id
);
$this
->
assertEquals
(
0
,
count
(
$order
->
books
));
$order
=
Order
::
find
()
->
where
([
'id'
=>
1
])
->
asArray
()
->
one
();
$this
->
assertTrue
(
is_array
(
$order
));
}
public
function
testFindEagerViaTable
()
...
...
@@ -146,6 +149,7 @@ class ActiveRecordTest extends DatabaseTestCase
// https://github.com/yiisoft/yii2/issues/1402
$orders
=
Order
::
find
()
->
with
(
'books'
)
->
orderBy
(
'id'
)
->
asArray
()
->
all
();
$this
->
assertEquals
(
3
,
count
(
$orders
));
$this
->
assertTrue
(
is_array
(
$orders
[
0
][
'orderItems'
][
0
]));
$order
=
$orders
[
0
];
$this
->
assertTrue
(
is_array
(
$order
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment