Skip to content

Commit

Permalink
Fixed escape character in like condition
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Apr 3, 2018
1 parent 6b0e466 commit b628a1c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ protected function defaultExpressionBuilders()
return array_merge(parent::defaultExpressionBuilders(), [
'yii\db\Expression' => 'edgardmessias\db\firebird\ExpressionBuilder',
'yii\db\conditions\InCondition' => 'edgardmessias\db\firebird\conditions\InConditionBuilder',
'yii\db\conditions\LikeCondition' => 'edgardmessias\db\firebird\conditions\LikeConditionBuilder',
]);
}

Expand Down
30 changes: 30 additions & 0 deletions src/conditions/LikeConditionBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/

namespace edgardmessias\db\firebird\conditions;

/**
* {@inheritdoc}
*/
class LikeConditionBuilder extends \yii\db\conditions\LikeConditionBuilder
{
/**
* {@inheritdoc}
*/
protected $escapeCharacter = '\\';

/**
* `\` is initialized in [[buildLikeCondition()]] method since
* we need to choose replacement value based on [[\yii\db\Schema::quoteValue()]].
* {@inheritdoc}
*/
protected $escapingReplacements = [
'%' => '\%',
'_' => '\_',
'\\' => '\\\\',
];
}

0 comments on commit b628a1c

Please sign in to comment.