Skip to content

Commit

Permalink
Merge pull request #5472 from kazuyoshikakihara/fix/postgresql_search…
Browse files Browse the repository at this point in the history
…_words_conversion

postgresql利用時のtranslateのFROMの修正
  • Loading branch information
chihiro-adachi authored Aug 1, 2022
2 parents bb6304b + 6a437d9 commit ef16a1a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Eccube/Doctrine/ORM/Query/Normalize.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class Normalize extends FunctionNode
{
protected $string;
public const FROM = 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをんがぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽぁぃぅぇぉっゃゅょわいえー';
public const FROM = 'あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをんがぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽぁぃぅぇぉっゃゅょゎゐゑー';
public const TO = 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポァィゥェォッャュョヮヰヱー';

public function parse(Parser $parser)
Expand Down
42 changes: 42 additions & 0 deletions tests/Eccube/Tests/Doctrine/ORM/Query/NormalizeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Eccube\Tests\Doctrine\ORM\Query;

use Eccube\Tests\EccubeTestCase;

class NormalizeTest extends EccubeTestCase
{
public function testGetSql()
{
$sql = $this->entityManager->createQueryBuilder()
->select('p.id')->from('Eccube\Entity\Product', 'p')
->where('NORMALIZE(p.name) LIKE :name')
->getQuery()->getSql();
switch ($this->entityManager->getConnection()->getDriver()->getDatabasePlatform()->getName())
{
case 'postgresql':
$this->assertStringContainsString('LOWER(TRANSLATE(', $sql);
$this->assertStringContainsString('あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをんがぎぐげござじずぜぞだぢづでどばびぶべぼぱぴぷぺぽぁぃぅぇぉっゃゅょゎゐゑー', $sql);
$this->assertStringContainsString('アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポァィゥェォッャュョヮヰヱー', $sql);
break;
case 'mysql':
$this->assertStringContainsString('CONVERT(', $sql);
$this->assertStringContainsString('USING utf8) COLLATE utf8_unicode_ci', $sql);
break;
case 'sqlite':
$this->assertStringContainsString('LOWER(', $sql);
break;
}
}
}

0 comments on commit ef16a1a

Please sign in to comment.