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
df22616c
Commit
df22616c
authored
Sep 22, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished fix for redis null and boolean value storage
fixes #1311
parent
f7fc1faa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
26 deletions
+29
-26
LuaScriptBuilder.php
extensions/redis/LuaScriptBuilder.php
+8
-6
Order.php
tests/unit/data/ar/redis/Order.php
+20
-2
ActiveRecordTest.php
tests/unit/extensions/redis/ActiveRecordTest.php
+1
-18
No files found.
extensions/redis/LuaScriptBuilder.php
View file @
df22616c
...
...
@@ -173,6 +173,7 @@ local pks={}
local n=0
local v=nil
local i=0
local key=$key
for k,pk in ipairs(allpks) do
$loadColumnValues
if $condition then
...
...
@@ -271,12 +272,13 @@ EOF;
if
(
is_bool
(
$value
))
{
$value
=
(
int
)
$value
;
}
$column
=
$this
->
addColumn
(
$column
,
$columns
);
if
(
$value
===
null
)
{
$parts
[]
=
"
$column
==nil
"
;
$parts
[]
=
"
redis.call('HEXISTS',key .. ':a:' .. pk, "
.
$this
->
quoteValue
(
$column
)
.
")==0
"
;
}
elseif
(
$value
instanceof
Expression
)
{
$column
=
$this
->
addColumn
(
$column
,
$columns
);
$parts
[]
=
"
$column
=="
.
$value
->
expression
;
}
else
{
$column
=
$this
->
addColumn
(
$column
,
$columns
);
$value
=
$this
->
quoteValue
(
$value
);
$parts
[]
=
"
$column
==
$value
"
;
}
...
...
@@ -359,7 +361,7 @@ EOF;
$value
=
isset
(
$value
[
$column
])
?
$value
[
$column
]
:
null
;
}
if
(
$value
===
null
)
{
$parts
[]
=
"
$columnAlias
==nil
"
;
$parts
[]
=
"
redis.call('HEXISTS',key .. ':a:' .. pk, "
.
$this
->
quoteValue
(
$column
)
.
")==0
"
;
}
elseif
(
$value
instanceof
Expression
)
{
$parts
[]
=
"
$columnAlias
=="
.
$value
->
expression
;
}
else
{
...
...
@@ -378,11 +380,11 @@ EOF;
foreach
(
$values
as
$value
)
{
$vs
=
[];
foreach
(
$inColumns
as
$column
)
{
$column
=
$this
->
addColumn
(
$column
,
$columns
);
if
(
isset
(
$value
[
$column
]))
{
$vs
[]
=
"
$column
=="
.
$this
->
quoteValue
(
$value
[
$column
]);
$columnAlias
=
$this
->
addColumn
(
$column
,
$columns
);
$vs
[]
=
"
$columnAlias
=="
.
$this
->
quoteValue
(
$value
[
$column
]);
}
else
{
$vs
[]
=
"
$column
==nil
"
;
$vs
[]
=
"
redis.call('HEXISTS',key .. ':a:' .. pk, "
.
$this
->
quoteValue
(
$column
)
.
")==0
"
;
}
}
$vss
[]
=
'('
.
implode
(
' and '
,
$vs
)
.
')'
;
...
...
tests/unit/data/ar/redis/Order.php
View file @
df22616c
...
...
@@ -33,6 +33,17 @@ class Order extends ActiveRecord
->
via
(
'orderItems'
)
->
indexBy
(
'id'
);
}
public
function
getItemsWithNullFK
()
{
return
$this
->
hasMany
(
Item
::
className
(),
[
'id'
=>
'item_id'
])
->
via
(
'orderItemsWithNullFK'
);
}
public
function
getOrderItemsWithNullFK
()
{
return
$this
->
hasMany
(
OrderItemWithNullFK
::
className
(),
[
'order_id'
=>
'id'
]);
}
public
function
getItemsInOrder1
()
{
return
$this
->
hasMany
(
Item
::
className
(),
[
'id'
=>
'item_id'
])
...
...
@@ -52,8 +63,15 @@ class Order extends ActiveRecord
public
function
getBooks
()
{
return
$this
->
hasMany
(
Item
::
className
(),
[
'id'
=>
'item_id'
])
->
via
(
'orderItems'
,
[
'order_id'
=>
'id'
]);
//->where(['category_id' => 1]);
->
via
(
'orderItems'
)
->
where
([
'category_id'
=>
1
]);
}
public
function
getBooksWithNullFK
()
{
return
$this
->
hasMany
(
Item
::
className
(),
[
'id'
=>
'item_id'
])
->
via
(
'orderItemsWithNullFK'
)
->
where
([
'category_id'
=>
1
]);
}
public
function
beforeSave
(
$insert
)
...
...
tests/unit/extensions/redis/ActiveRecordTest.php
View file @
df22616c
...
...
@@ -143,24 +143,6 @@ class ActiveRecordTest extends RedisTestCase
}
public
function
testFindNullValues
()
{
// https://github.com/yiisoft/yii2/issues/1311
$this
->
markTestSkipped
(
'Redis does not store/find null values correctly.'
);
}
public
function
testUnlinkAll
()
{
// https://github.com/yiisoft/yii2/issues/1311
$this
->
markTestSkipped
(
'Redis does not store/find null values correctly.'
);
}
public
function
testUnlink
()
{
// https://github.com/yiisoft/yii2/issues/1311
$this
->
markTestSkipped
(
'Redis does not store/find null values correctly.'
);
}
public
function
testFindEagerViaRelationPreserveOrder
()
{
$this
->
markTestSkipped
(
'Redis does not support orderBy.'
);
...
...
@@ -267,6 +249,7 @@ class ActiveRecordTest extends RedisTestCase
public
function
testFindColumn
()
{
// TODO this test is duplicated because of missing orderBy support in redis
$this
->
assertEquals
([
'user1'
,
'user2'
,
'user3'
],
Customer
::
find
()
->
column
(
'name'
));
// TODO $this->assertEquals(['user3', 'user2', 'user1'], Customer::find()->orderBy(['name' => SORT_DESC])->column('name'));
}
...
...
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