-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Tester\Assert; | ||
|
||
require __DIR__ . '/bootstrap.php'; | ||
|
||
|
||
$conn = new Dibi\Connection($config); | ||
|
||
// starts with | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %like~', 'a', 'b')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %like~', 'baa', 'aa')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %like~', 'aab', 'aa')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %like~', 'bba', '%a')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %like~', '%ba', '%a')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %like~', '%ab', '%a')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %like~', 'aa', '_a')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %like~', '_b', '_a')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %like~', '_ab', '_a')); | ||
|
||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %like~', 'a"a', 'a"')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %like~', 'b"', '%"')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %like~', '%"', '%"')); | ||
|
||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %like~', "a'a", "a'")); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %like~', "b'", "%'")); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %like~', "%'", "%'")); | ||
|
||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %like~', 'a\\a', 'a\\')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %like~', 'b\\', '%\\')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %like~', '%\\', '%\\')); | ||
|
||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %like~', 'a[a', 'a[')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %like~', 'b[', '%[')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %like~', '%[', '%[')); | ||
|
||
|
||
// ends with | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %~like', 'a', 'b')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %~like', 'baa', 'aa')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %~like', 'aab', 'aa')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %~like', 'bba', '%a')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %~like', 'a%b', '%a')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %~like', 'b%a', '%a')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %~like', 'aa', '_a')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %~like', '_b', '_a')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %~like', 'b_a', '_a')); | ||
|
||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %~like', 'a"a', '"a')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %~like', '"b', '"%')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %~like', '"%', '"%')); | ||
|
||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %~like', "a'a", "'a")); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %~like', "'b", "'%")); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %~like', "'%", "'%")); | ||
|
||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %~like', 'a\\a', '\\a')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %~like', '\\b', '\\%')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %~like', '\\%', '\\%')); | ||
|
||
|
||
// contains | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %~like~', 'a', 'b')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %~like~', 'baa', 'aa')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %~like~', 'aab', 'aa')); | ||
Assert::same(0, $conn->fetchSingle('SELECT ? LIKE %~like~', 'bba', '%a')); | ||
Assert::same(1, $conn->fetchSingle('SELECT ? LIKE %~like~', 'b%a', '%a')); |
0fb63f3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test jsem nepsal, jen jsem to testoval hlavně v souvislosti s ublaboo datagridem a DIBI datasource a nic chybného v LIKE mi to negenerovalo. Zkoušel jsem dost možností a ten escape \
0fb63f3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tak zkus, jestli funguje i s Firebirdem.
0fb63f3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testoval jsem to přímo na Firebird 2.5 . Verzi 3x nikde zatím nikde nemám instalovanou.
Samotný LIKE nevykazoval žádné anomálie.
Spíš ten myslím, že DIBI datasource pro ublaboo se nad firebirdem chová trochu nestandardně, myslím dává názvy sloupců do "", ale když udělám dotaz přímo nad DIBI fluentu taj je to OK.
0fb63f3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nezkoušel jsem spuštěním toho testu, zatím jen v aplikaci s napojením na Firebird 2.5.