Skip to content

Commit 947ac53

Browse files
committed
Comment option 2
1 parent f09ff81 commit 947ac53

3 files changed

Lines changed: 21 additions & 15 deletions

File tree

src/Database/Database.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6675,19 +6675,19 @@ public static function convertQueries(Document $collection, array $queries): arr
66756675
foreach ($attributes as $attribute) {
66766676
foreach ($queries as $index => $query) {
66776677
if ($query->getAttribute() === $attribute->getId()) {
6678-
if($query->getAttribute() === '$sequence'){
6679-
/**
6680-
* Hack for Postgres, since bindParam does not convert '' on int attribute
6681-
*/
6682-
$values = $query->getValues();
6683-
foreach ($values as $valueIndex => $value) {
6684-
if($value === ''){
6685-
$values[$valueIndex] = '0';
6686-
}
6687-
}
6688-
$query->setValues($values);
6689-
$queries[$index] = $query;
6690-
}
6678+
// if($query->getAttribute() === '$sequence'){
6679+
// /**
6680+
// * Hack for Postgres, since bindParam does not convert '' on int attribute
6681+
// */
6682+
// $values = $query->getValues();
6683+
// foreach ($values as $valueIndex => $value) {
6684+
// if($value === ''){
6685+
// $values[$valueIndex] = '0';
6686+
// }
6687+
// }
6688+
// $query->setValues($values);
6689+
// $queries[$index] = $query;
6690+
// }
66916691

66926692
$query->setOnArray($attribute->getAttribute('array', false));
66936693
}

src/Database/Document.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ public function getId(): string
6666
*/
6767
public function getSequence(): string
6868
{
69-
return $this->getAttribute('$sequence', '');
69+
/**
70+
* This can be a better fix ?
71+
* Since we always check logic by empty($document->getSequence()
72+
*/
73+
return $this->getAttribute('$sequence', '0');
74+
//return $this->getAttribute('$sequence', '');
7075
}
7176

7277
/**

tests/e2e/Adapter/Scopes/DocumentTests.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1786,9 +1786,10 @@ public function testFindByInternalID(array $data): void
17861786
* We should not use this fix and use structure validations, or change using not querying on empty string
17871787
*/
17881788
$empty = new Document();
1789+
$this->assertEquals('0', $empty->getSequence());
17891790

17901791
/**
1791-
* Check no exceptions are thrown as a temporary fix
1792+
* Check no exceptions is thrown
17921793
*/
17931794
$database->find('movies', [
17941795
Query::equal('$sequence', [$empty->getSequence()]),

0 commit comments

Comments
 (0)