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
e5919cf4
Commit
e5919cf4
authored
Jun 24, 2014
by
Paul Klimov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4034 from klimov-paul/4018-sphinx-db-relation-composite-link
Fix #4018: sphinx db relation composite link
parents
06235cd1
88717511
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
2 deletions
+26
-2
ActiveRecord.php
extensions/sphinx/ActiveRecord.php
+7
-2
CHANGELOG.md
extensions/sphinx/CHANGELOG.md
+1
-0
ArticleIndex.php
tests/unit/data/ar/sphinx/ArticleIndex.php
+5
-0
ActiveRelationTest.php
tests/unit/extensions/sphinx/ActiveRelationTest.php
+13
-0
No files found.
extensions/sphinx/ActiveRecord.php
View file @
e5919cf4
...
@@ -618,8 +618,13 @@ abstract class ActiveRecord extends BaseActiveRecord
...
@@ -618,8 +618,13 @@ abstract class ActiveRecord extends BaseActiveRecord
{
{
$columns
=
static
::
getIndexSchema
()
->
columns
;
$columns
=
static
::
getIndexSchema
()
->
columns
;
foreach
(
$row
as
$name
=>
$value
)
{
foreach
(
$row
as
$name
=>
$value
)
{
if
(
isset
(
$columns
[
$name
])
&&
$columns
[
$name
]
->
isMva
)
{
if
(
isset
(
$columns
[
$name
]))
{
$row
[
$name
]
=
explode
(
','
,
$value
);
if
(
$columns
[
$name
]
->
isMva
)
{
$mvaValue
=
explode
(
','
,
$value
);
$row
[
$name
]
=
array_map
(
array
(
$columns
[
$name
],
'typecast'
),
$mvaValue
);
}
else
{
$row
[
$name
]
=
$columns
[
$name
]
->
typecast
(
$value
);
}
}
}
}
}
parent
::
populateRecord
(
$record
,
$row
);
parent
::
populateRecord
(
$record
,
$row
);
...
...
extensions/sphinx/CHANGELOG.md
View file @
e5919cf4
...
@@ -5,6 +5,7 @@ Yii Framework 2 sphinx extension Change Log
...
@@ -5,6 +5,7 @@ Yii Framework 2 sphinx extension Change Log
--------------------------
--------------------------
-
Bug #3668: Escaping of the special characters at 'MATCH' statement added (klimov-paul)
-
Bug #3668: Escaping of the special characters at 'MATCH' statement added (klimov-paul)
-
Bug #4018: AR relation eager loading does not work with db models (klimov-paul)
-
Enh: Added support for using sub-queries when building a DB query with
`IN`
condition (qiangxue)
-
Enh: Added support for using sub-queries when building a DB query with
`IN`
condition (qiangxue)
-
Enh #3520: Added
`unlinkAll()`
-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
-
Enh #3520: Added
`unlinkAll()`
-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
...
...
tests/unit/data/ar/sphinx/ArticleIndex.php
View file @
e5919cf4
...
@@ -18,6 +18,11 @@ class ArticleIndex extends ActiveRecord
...
@@ -18,6 +18,11 @@ class ArticleIndex extends ActiveRecord
return
$this
->
hasOne
(
ArticleDb
::
className
(),
[
'id'
=>
'id'
]);
return
$this
->
hasOne
(
ArticleDb
::
className
(),
[
'id'
=>
'id'
]);
}
}
public
function
getSourceCompositeLink
()
{
return
$this
->
hasOne
(
ArticleDb
::
className
(),
[
'id'
=>
'id'
,
'author_id'
=>
'author_id'
]);
}
public
function
getTags
()
public
function
getTags
()
{
{
return
$this
->
hasMany
(
TagDb
::
className
(),
[
'id'
=>
'tag'
]);
return
$this
->
hasMany
(
TagDb
::
className
(),
[
'id'
=>
'tag'
]);
...
...
tests/unit/extensions/sphinx/ActiveRelationTest.php
View file @
e5919cf4
...
@@ -42,4 +42,17 @@ class ActiveRelationTest extends SphinxTestCase
...
@@ -42,4 +42,17 @@ class ActiveRelationTest extends SphinxTestCase
$this
->
assertTrue
(
$articles
[
0
]
->
index
instanceof
ArticleIndex
);
$this
->
assertTrue
(
$articles
[
0
]
->
index
instanceof
ArticleIndex
);
$this
->
assertTrue
(
$articles
[
1
]
->
index
instanceof
ArticleIndex
);
$this
->
assertTrue
(
$articles
[
1
]
->
index
instanceof
ArticleIndex
);
}
}
/**
* @see https://github.com/yiisoft/yii2/issues/4018
*/
public
function
testFindCompositeLink
()
{
$articles
=
ArticleIndex
::
find
()
->
with
(
'sourceCompositeLink'
)
->
all
();
$this
->
assertEquals
(
2
,
count
(
$articles
));
$this
->
assertTrue
(
$articles
[
0
]
->
isRelationPopulated
(
'sourceCompositeLink'
));
$this
->
assertNotEmpty
(
$articles
[
0
]
->
sourceCompositeLink
);
$this
->
assertTrue
(
$articles
[
1
]
->
isRelationPopulated
(
'sourceCompositeLink'
));
$this
->
assertNotEmpty
(
$articles
[
1
]
->
sourceCompositeLink
);
}
}
}
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