-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Selection: fixed bug with zero in primary key
- Loading branch information
Showing
2 changed files
with
38 additions
and
2 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
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,36 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Zero Primary key bug | ||
* @dataProvider? ../../databases.ini mysql | ||
*/ | ||
|
||
use Tester\Assert; | ||
|
||
require __DIR__ . '/../../connect.inc.php'; | ||
|
||
$context->query('CREATE DATABASE IF NOT EXISTS nette_test'); | ||
$context->query('USE nette_test'); | ||
|
||
$context->query(' | ||
CREATE TABLE ships ( | ||
id INTEGER PRIMARY KEY NOT NULL, | ||
name TEXT NOT NULL | ||
); | ||
'); | ||
|
||
$context->query(' | ||
INSERT INTO ships (id, name) VALUES(2, "Enterprise"); | ||
'); | ||
|
||
$context->query(' | ||
INSERT INTO ships (id, name) VALUES(0, "Endeavour"); | ||
'); | ||
|
||
Assert::same(2, $context->table('ships')->order('id DESC')->count()); | ||
|
||
$result = $context->table('ships')->order('id DESC')->fetchAll(); // SELECT * FROM `ships` ORDER BY id DESC | ||
|
||
Assert::same("Enterprise", $result[2]->name); | ||
|
||
Assert::same("Endeavour", $result[0]->name); |