Skip to content

Commit e03357a

Browse files
committed
fixes the limit operation
1 parent 696de1c commit e03357a

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

src/Processor/Processor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected static function applyLimit(?LimitClause $limit, Scope $scope, QueryRes
125125
}
126126

127127
return new QueryResult(
128-
\array_slice($result->rows, $offset, $rowcount),
128+
\array_slice($result->rows, $offset, $rowcount, true),
129129
$result->columns
130130
);
131131
}

tests/EndToEndTest.php

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -826,18 +826,6 @@ public function testSelectHavingOnAliasField()
826826
);
827827
}
828828

829-
public function testSelectWithOffset()
830-
{
831-
$pdo = self::getConnectionToFullDB(false);
832-
$query = $pdo->prepare("SELECT `id` FROM `video_game_characters` ORDER BY `id` LIMIT 10000 OFFSET 1");
833-
$query->execute();
834-
835-
$this->assertSame(
836-
['id' => 2],
837-
$query->fetch(\PDO::FETCH_ASSOC)
838-
);
839-
}
840-
841829
public function testLastInsertIdAfterSkippingAutoincrement()
842830
{
843831
$pdo = self::getConnectionToFullDB(false);
@@ -1214,6 +1202,25 @@ public function testSelectNullableFields()
12141202
$query->fetch(\PDO::FETCH_ASSOC)
12151203
);
12161204
}
1205+
1206+
public function testUpdate()
1207+
{
1208+
$pdo = self::getConnectionToFullDB(false);
1209+
1210+
// before update
1211+
$query = $pdo->prepare("SELECT `type` FROM `video_game_characters` WHERE `id` = 3");
1212+
$query->execute();
1213+
$this->assertSame([['type' => 'hero']], $query->fetchAll(\PDO::FETCH_ASSOC));
1214+
1215+
// prepare update
1216+
$query = $pdo->prepare("UPDATE `video_game_characters` SET `type` = 'villain' WHERE `id` = 3 LIMIT 1");
1217+
$query->execute();
1218+
1219+
// after update
1220+
$query = $pdo->prepare("SELECT `type` FROM `video_game_characters` WHERE `id` = 3");
1221+
$query->execute();
1222+
$this->assertSame([['type' => 'villain']], $query->fetchAll(\PDO::FETCH_ASSOC));
1223+
}
12171224

12181225
public function testNegateOperationWithAnd()
12191226
{

0 commit comments

Comments
 (0)