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
dc3ada65
Commit
dc3ada65
authored
Nov 28, 2013
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mongo query "IN" condition shortcut syntax added.
parent
a0384498
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
Collection.php
extensions/mongo/Collection.php
+7
-1
QueryRunTest.php
tests/unit/extensions/mongo/QueryRunTest.php
+1
-3
No files found.
extensions/mongo/Collection.php
View file @
dc3ada65
...
...
@@ -242,7 +242,13 @@ class Collection extends Object
if
(
is_numeric
(
$key
))
{
$result
[]
=
$actualValue
;
}
else
{
$result
[
$this
->
normalizeConditionKeyword
(
$key
)]
=
$actualValue
;
$key
=
$this
->
normalizeConditionKeyword
(
$key
);
if
(
strncmp
(
'$'
,
$key
,
1
)
!==
0
&&
array_key_exists
(
0
,
$actualValue
))
{
// shortcut for IN condition
$result
[
$key
][
'$in'
]
=
$actualValue
;
}
else
{
$result
[
$key
]
=
$actualValue
;
}
}
}
return
$result
;
...
...
tests/unit/extensions/mongo/QueryRunTest.php
View file @
dc3ada65
...
...
@@ -75,9 +75,7 @@ class QueryRunTest extends MongoTestCase
$query
=
new
Query
;
$rows
=
$query
->
from
(
'customer'
)
->
where
([
'name'
=>
[
'in'
=>
[
'name1'
,
'name5'
]
]
'name'
=>
[
'name1'
,
'name5'
]
])
->
all
(
$connection
);
$this
->
assertEquals
(
2
,
count
(
$rows
));
...
...
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