Skip to content

Commit

Permalink
Fixed using functions for processing input when creating sorting SQL …
Browse files Browse the repository at this point in the history
…strings
  • Loading branch information
aimeos committed Jun 5, 2020
1 parent 3b0ef3a commit dae079c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Common/Manager/Base.php
Expand Up @@ -918,7 +918,7 @@ protected function getSQLReplacements( \Aimeos\MW\Criteria\Iface $search, array
$replace[] = $search->getSortationSource( $types, $translations, $funcs );

$find[] = ':group';
$replace[] = implode( ', ', $search->translate( $search->getSortations(), $translations ) ) . ', ';
$replace[] = implode( ', ', $search->translate( $search->getSortations(), $translations, $funcs ) ) . ', ';

return [$find, $replace];
}
Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Index/Manager/DBBase.php
Expand Up @@ -309,8 +309,8 @@ protected function getSQLReplacements( \Aimeos\MW\Criteria\Iface $search, array
}
elseif( !empty( $search->getSortations() ) )
{
$names = $search->translate( $search->getSortations() );
$cols = $search->translate( $search->getSortations(), $translations );
$names = $search->translate( $search->getSortations(), [], $funcs );
$cols = $search->translate( $search->getSortations(), $translations, $funcs );

$list = $translations = [];
foreach( $cols as $idx => $col )
Expand Down
3 changes: 2 additions & 1 deletion lib/mwlib/src/MW/Criteria/Base.php
Expand Up @@ -275,9 +275,10 @@ public function parse( array $array ) : ?\Aimeos\MW\Criteria\Expression\Iface
*
* @param array $columns List of objects implementing getName() method
* @param array $translations Associative list of item names that should be translated
* @param array $funcs Associative list of item names and functions modifying the conditions
* @return array List of translated columns
*/
public function translate( array $columns, array $translations = [] ) : array
public function translate( array $columns, array $translations = [], array $funcs = [] ) : array
{
$list = [];

Expand Down
7 changes: 4 additions & 3 deletions lib/mwlib/src/MW/Criteria/Expression/Traits.php
Expand Up @@ -47,12 +47,13 @@ public static function createFunction( string $name, array $params ) : string
* Translates the sort key into the name required by the storage
*
* @param array $translations Associative list of variable or column names that should be translated
* @return string|null Translated name (with replaced parameters if the name is an expression function)
* @param array $funcs Associative list of item names and functions modifying the conditions
* @return string Translated name (with replaced parameters if the name is an expression function)
*/
public function translate( array $translations ) : ?string
public function translate( array $translations, array $funcs = [] ) : ?string
{
$name = $this->getName();
return $this->translateName( $name, $translations );
return $this->translateName( $name, $translations, $funcs );
}


Expand Down

0 comments on commit dae079c

Please sign in to comment.