Skip to content

Commit 31d3db1

Browse files
committed
Add gin index support check
1 parent 4f02d63 commit 31d3db1

6 files changed

Lines changed: 28 additions & 1 deletion

File tree

src/Database/Adapter.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,13 @@ abstract public function getSupportForIndexArray(): bool;
979979
*/
980980
abstract public function getSupportForCastIndexArray(): bool;
981981

982+
/**
983+
* Does the adapter use GIN indexes for array columns?
984+
*
985+
* @return bool
986+
*/
987+
abstract public function getSupportForGinIndex(): bool;
988+
982989
/**
983990
* Is unique index supported?
984991
*

src/Database/Adapter/Mongo.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,6 +3221,11 @@ public function getSupportForCastIndexArray(): bool
32213221
return false;
32223222
}
32233223

3224+
public function getSupportForGinIndex(): bool
3225+
{
3226+
return false;
3227+
}
3228+
32243229
public function getSupportForUpserts(): bool
32253230
{
32263231
return true;

src/Database/Adapter/Pool.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ public function getSupportForCastIndexArray(): bool
388388
return $this->delegate(__FUNCTION__, \func_get_args());
389389
}
390390

391+
public function getSupportForGinIndex(): bool
392+
{
393+
return $this->delegate(__FUNCTION__, \func_get_args());
394+
}
395+
391396
public function getSupportForUniqueIndex(): bool
392397
{
393398
return $this->delegate(__FUNCTION__, \func_get_args());

src/Database/Adapter/Postgres.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,6 +2142,11 @@ public function getSupportForCastIndexArray(): bool
21422142
return true;
21432143
}
21442144

2145+
public function getSupportForGinIndex(): bool
2146+
{
2147+
return true;
2148+
}
2149+
21452150
/**
21462151
* Does the adapter handle Query Array Overlaps?
21472152
*

src/Database/Adapter/SQL.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,11 @@ public function getSupportForCastIndexArray(): bool
15451545
return false;
15461546
}
15471547

1548+
public function getSupportForGinIndex(): bool
1549+
{
1550+
return false;
1551+
}
1552+
15481553
public function getSupportForRelationships(): bool
15491554
{
15501555
return true;

tests/e2e/Adapter/Scopes/IndexTests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ public function testArrayIndexUsedInQuery(): void
11501150
$ns = $database->getNamespace();
11511151
$db = $database->getDatabase();
11521152

1153-
if ($adapter instanceof \Utopia\Database\Adapter\Postgres) {
1153+
if ($adapter->getSupportForGinIndex()) {
11541154
$table = "\"{$db}\".\"{$ns}_{$collection}\"";
11551155

11561156
// Verify GIN index exists

0 commit comments

Comments
 (0)