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
ece300ac
Commit
ece300ac
authored
Sep 22, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed null value adjustment in redis ActiveQuery
asArray will not include null valued keys
parent
df22616c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
16 deletions
+38
-16
ActiveQuery.php
extensions/redis/ActiveQuery.php
+0
-16
ActiveRecordTest.php
tests/unit/extensions/redis/ActiveRecordTest.php
+38
-0
No files found.
extensions/redis/ActiveQuery.php
View file @
ece300ac
...
...
@@ -124,14 +124,6 @@ class ActiveQuery extends Component implements ActiveQueryInterface
$row
[
$dataRow
[
$i
++
]]
=
$dataRow
[
$i
++
];
}
$class
=
$this
->
modelClass
;
$modelInstance
=
$class
::
instantiate
(
$row
);
foreach
(
$modelInstance
->
attributes
()
as
$attribute
)
{
if
(
!
isset
(
$row
[
$attribute
]))
{
$row
[
$attribute
]
=
null
;
}
}
$rows
[]
=
$row
;
}
if
(
!
empty
(
$rows
))
{
...
...
@@ -173,14 +165,6 @@ class ActiveQuery extends Component implements ActiveQueryInterface
}
if
(
$this
->
asArray
)
{
$model
=
$row
;
$class
=
$this
->
modelClass
;
$modelInstance
=
$class
::
instantiate
(
$row
);
foreach
(
$modelInstance
->
attributes
()
as
$attribute
)
{
if
(
!
isset
(
$model
[
$attribute
]))
{
$model
[
$attribute
]
=
null
;
}
}
}
else
{
/* @var $class ActiveRecord */
$class
=
$this
->
modelClass
;
...
...
tests/unit/extensions/redis/ActiveRecordTest.php
View file @
ece300ac
...
...
@@ -153,6 +153,44 @@ class ActiveRecordTest extends RedisTestCase
$this
->
markTestSkipped
(
'Redis does not support orderBy.'
);
}
/**
* overridden because null values are not part of the asArray result in redis
*/
public
function
testFindAsArray
()
{
/* @var $customerClass \yii\db\ActiveRecordInterface */
$customerClass
=
$this
->
getCustomerClass
();
// asArray
$customer
=
$customerClass
::
find
()
->
where
([
'id'
=>
2
])
->
asArray
()
->
one
();
$this
->
assertEquals
([
'id'
=>
2
,
'email'
=>
'user2@example.com'
,
'name'
=>
'user2'
,
'address'
=>
'address2'
,
'status'
=>
1
,
],
$customer
);
// find all asArray
$customers
=
$customerClass
::
find
()
->
asArray
()
->
all
();
$this
->
assertEquals
(
3
,
count
(
$customers
));
$this
->
assertArrayHasKey
(
'id'
,
$customers
[
0
]);
$this
->
assertArrayHasKey
(
'name'
,
$customers
[
0
]);
$this
->
assertArrayHasKey
(
'email'
,
$customers
[
0
]);
$this
->
assertArrayHasKey
(
'address'
,
$customers
[
0
]);
$this
->
assertArrayHasKey
(
'status'
,
$customers
[
0
]);
$this
->
assertArrayHasKey
(
'id'
,
$customers
[
1
]);
$this
->
assertArrayHasKey
(
'name'
,
$customers
[
1
]);
$this
->
assertArrayHasKey
(
'email'
,
$customers
[
1
]);
$this
->
assertArrayHasKey
(
'address'
,
$customers
[
1
]);
$this
->
assertArrayHasKey
(
'status'
,
$customers
[
1
]);
$this
->
assertArrayHasKey
(
'id'
,
$customers
[
2
]);
$this
->
assertArrayHasKey
(
'name'
,
$customers
[
2
]);
$this
->
assertArrayHasKey
(
'email'
,
$customers
[
2
]);
$this
->
assertArrayHasKey
(
'address'
,
$customers
[
2
]);
$this
->
assertArrayHasKey
(
'status'
,
$customers
[
2
]);
}
public
function
testStatisticalFind
()
{
// find count, sum, average, min, max, scalar
...
...
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