diff --git a/src/Database/Adapter/Postgres.php b/src/Database/Adapter/Postgres.php index 4d77772aa..58c122492 100644 --- a/src/Database/Adapter/Postgres.php +++ b/src/Database/Adapter/Postgres.php @@ -1558,11 +1558,7 @@ public function find(string $collection, array $queries = [], ?int $limit = 25, try { $stmt = $this->getPDO()->prepare($sql); foreach ($binds as $key => $value) { - if ($key === ":sequence") { - $stmt->bindValue($key, $value, PDO::PARAM_INT); - } else { - $stmt->bindValue($key, $value, $this->getPDOType($value)); - } + $stmt->bindValue($key, $value, $this->getPDOType($value)); } $this->execute($stmt); @@ -1822,13 +1818,9 @@ protected function getSQLCondition(Query $query, array &$binds): string Query::TYPE_CONTAINS => $query->onArray() ? \json_encode($value) : '%' . $this->escapeWildcards($value) . '%', default => $value }; - if ($attribute === $this->quote("_id")) { - $binds[":sequence"] = $value; - $conditions[] = "{$alias}.{$attribute} {$operator} :sequence"; - } else { - $binds[":{$placeholder}_{$key}"] = $value; - $conditions[] = "{$alias}.{$attribute} {$operator} :{$placeholder}_{$key}"; - } + + $binds[":{$placeholder}_{$key}"] = $value; + $conditions[] = "{$alias}.{$attribute} {$operator} :{$placeholder}_{$key}"; } return empty($conditions) ? '' : '(' . implode(' OR ', $conditions) . ')'; diff --git a/tests/e2e/Adapter/Scopes/DocumentTests.php b/tests/e2e/Adapter/Scopes/DocumentTests.php index 1d5208df9..d5f3bdec8 100644 --- a/tests/e2e/Adapter/Scopes/DocumentTests.php +++ b/tests/e2e/Adapter/Scopes/DocumentTests.php @@ -1845,6 +1845,9 @@ public function testFindByInternalID(array $data): void ]); $this->assertEquals(1, count($documents)); + + $empty = new Document(); + $this->assertEquals('', $empty->getSequence()); } public function testFindOrderBy(): void