From 46280806236fedabb9a43e0517817c17c9b0d6bd Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Thu, 3 Sep 2020 11:12:52 +0200 Subject: escape ID to avoid postgresql lowercasing it --- test/it_dbi.t | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/it_dbi.t') diff --git a/test/it_dbi.t b/test/it_dbi.t index 4341991..8039857 100755 --- a/test/it_dbi.t +++ b/test/it_dbi.t @@ -362,13 +362,13 @@ $r->update(['key4' => "val4'", 'key5' => "val5'"]); is($r->_writes, 1); is($r- $r->update(['key4' => "val4'", 'key5' => "val5'"]); is($r->_writes, 1); is($r->key4, "val4'"); is($r->key5, "val5'"); # Check LIMIT -$count = $r->select(['ID >' => 0, 'ORDER BY ID DESC', 'LIMIT' => 1]); +$count = $r->select(['ID >' => 0, "ORDER BY $primarykey DESC", 'LIMIT' => 1]); is($count, 1, "Simple LIMIT: count"); is($r->ID, 6, "Simple LIMIT: id"); -$count = $r->select(['ID >' => 0, 'ORDER BY ID DESC', 'LIMIT' => "1, 2"]); +$count = $r->select(['ID >' => 0, "ORDER BY $primarykey DESC", 'LIMIT' => "1, 2"]); is($count, 2, "LIMIT with offset: count"); is($r->ID, 5, "LIMIT with offset: id"); -is($r->select(['ID >' => 0, 'ORDER BY ID DESC', 'LIMIT' => false]), 5, "no limit"); +is($r->select(['ID >' => 0, "ORDER BY $primarykey DESC", 'LIMIT' => false]), 5, "no limit"); # Check if iterator clears dynfields left over from previous record $r->delete(["WHERE 1"]); @@ -376,7 +376,7 @@ $r->replace(['ID' => 1, 'key1' => "a"]); $r->replace(['ID' => 2, 'key2' => "b"]); $r->replace(['ID' => 3]); $r->clear(false); -$r->select("WHERE 1 ORDER BY ID"); +$r->select("WHERE 1 ORDER BY $primarykey"); $r->iterate(); is($r->key1, "a"); is($r->key2, null); $r->iterate(); @@ -406,7 +406,7 @@ is($r->_where(['LOWER(a)' => 'x']), "WHERE LOWER(a) = 'x'", "don't do JSON_EXTRA # function allrecs() { - foreach (new it_dbi_test([0 => "ORDER BY ID"]) as $r) + foreach (new it_dbi_test([0 => "ORDER BY $GLOBALS[primarykey]"]) as $r) $result[] = ['ID' => $r->ID, 'foo' => $r->foo]; return json_encode($result); } -- cgit v1.2.3