Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/Database/Adapter/Postgres.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -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);
Expand DownExpand Up@@ -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) . ')';
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/Adapter/Scopes/DocumentTests.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand Down