Skip to content

Commit 670e8ef

Browse files
authored
Merge pull request #661 from ArnabChatterjee20k/spatial-attribute-support
Spatial attribute support
2 parents 6284aaa + 07e7de7 commit 670e8ef

File tree

17 files changed

+3130
-152
lines changed

17 files changed

+3130
-152
lines changed

docker-compose.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ services:
3030
- database
3131

3232
postgres:
33-
image: postgres:16.4
33+
build:
34+
context: .
35+
dockerfile: postgres.dockerfile
36+
args:
37+
POSTGRES_VERSION: 16
3438
container_name: utopia-postgres
3539
networks:
3640
- database
@@ -39,9 +43,14 @@ services:
3943
environment:
4044
POSTGRES_USER: root
4145
POSTGRES_PASSWORD: password
46+
POSTGRES_DB: root
4247

4348
postgres-mirror:
44-
image: postgres:16.4
49+
build:
50+
context: .
51+
dockerfile: postgres.dockerfile
52+
args:
53+
POSTGRES_VERSION: 16
4554
container_name: utopia-postgres-mirror
4655
networks:
4756
- database
@@ -50,6 +59,7 @@ services:
5059
environment:
5160
POSTGRES_USER: root
5261
POSTGRES_PASSWORD: password
62+
POSTGRES_DB: root
5363

5464
mariadb:
5565
image: mariadb:10.11

postgres.dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM postgres:16
2+
3+
RUN apt-get update \
4+
&& apt-get install -y --no-install-recommends \
5+
postgresql-16-postgis-3 \
6+
postgresql-16-postgis-3-scripts \
7+
&& rm -rf /var/lib/apt/lists/*

src/Database/Adapter.php

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ abstract public function analyzeCollection(string $collection): bool;
534534
* @throws TimeoutException
535535
* @throws DuplicateException
536536
*/
537-
abstract public function createAttribute(string $collection, string $id, string $type, int $size, bool $signed = true, bool $array = false): bool;
537+
abstract public function createAttribute(string $collection, string $id, string $type, int $size, bool $signed = true, bool $array = false, bool $required = false): bool;
538538

539539
/**
540540
* Create Attributes
@@ -661,75 +661,75 @@ abstract public function deleteIndex(string $collection, string $id): bool;
661661
/**
662662
* Get Document
663663
*
664-
* @param string $collection
664+
* @param Document $collection
665665
* @param string $id
666666
* @param array<Query> $queries
667667
* @param bool $forUpdate
668668
* @return Document
669669
*/
670-
abstract public function getDocument(string $collection, string $id, array $queries = [], bool $forUpdate = false): Document;
670+
abstract public function getDocument(Document $collection, string $id, array $queries = [], bool $forUpdate = false): Document;
671671

672672
/**
673673
* Create Document
674674
*
675-
* @param string $collection
675+
* @param Document $collection
676676
* @param Document $document
677677
*
678678
* @return Document
679679
*/
680-
abstract public function createDocument(string $collection, Document $document): Document;
680+
abstract public function createDocument(Document $collection, Document $document): Document;
681681

682682
/**
683683
* Create Documents in batches
684684
*
685-
* @param string $collection
685+
* @param Document $collection
686686
* @param array<Document> $documents
687687
*
688688
* @return array<Document>
689689
*
690690
* @throws DatabaseException
691691
*/
692-
abstract public function createDocuments(string $collection, array $documents): array;
692+
abstract public function createDocuments(Document $collection, array $documents): array;
693693

694694
/**
695695
* Update Document
696696
*
697-
* @param string $collection
697+
* @param Document $collection
698698
* @param string $id
699699
* @param Document $document
700700
* @param bool $skipPermissions
701701
*
702702
* @return Document
703703
*/
704-
abstract public function updateDocument(string $collection, string $id, Document $document, bool $skipPermissions): Document;
704+
abstract public function updateDocument(Document $collection, string $id, Document $document, bool $skipPermissions): Document;
705705

706706
/**
707707
* Update documents
708708
*
709709
* Updates all documents which match the given query.
710710
*
711-
* @param string $collection
711+
* @param Document $collection
712712
* @param Document $updates
713713
* @param array<Document> $documents
714714
*
715715
* @return int
716716
*
717717
* @throws DatabaseException
718718
*/
719-
abstract public function updateDocuments(string $collection, Document $updates, array $documents): int;
719+
abstract public function updateDocuments(Document $collection, Document $updates, array $documents): int;
720720

721721
/**
722722
* Create documents if they do not exist, otherwise update them.
723723
*
724724
* If attribute is not empty, only the specified attribute will be increased, by the new value in each document.
725725
*
726-
* @param string $collection
726+
* @param Document $collection
727727
* @param string $attribute
728728
* @param array<Change> $changes
729729
* @return array<Document>
730730
*/
731731
abstract public function createOrUpdateDocuments(
732-
string $collection,
732+
Document $collection,
733733
string $attribute,
734734
array $changes
735735
): array;
@@ -767,7 +767,7 @@ abstract public function deleteDocuments(string $collection, array $sequences, a
767767
*
768768
* Find data sets using chosen queries
769769
*
770-
* @param string $collection
770+
* @param Document $collection
771771
* @param array<Query> $queries
772772
* @param int|null $limit
773773
* @param int|null $offset
@@ -776,10 +776,9 @@ abstract public function deleteDocuments(string $collection, array $sequences, a
776776
* @param array<string, mixed> $cursor
777777
* @param string $cursorDirection
778778
* @param string $forPermission
779-
*
780779
* @return array<Document>
781780
*/
782-
abstract public function find(string $collection, array $queries = [], ?int $limit = 25, ?int $offset = null, array $orderAttributes = [], array $orderTypes = [], array $cursor = [], string $cursorDirection = Database::CURSOR_AFTER, string $forPermission = Database::PERMISSION_READ): array;
781+
abstract public function find(Document $collection, array $queries = [], ?int $limit = 25, ?int $offset = null, array $orderAttributes = [], array $orderTypes = [], array $cursor = [], string $cursorDirection = Database::CURSOR_AFTER, string $forPermission = Database::PERMISSION_READ): array;
783782

784783
/**
785784
* Sum an attribute
@@ -1029,6 +1028,34 @@ abstract public function getSupportForHostname(): bool;
10291028
*/
10301029
abstract public function getSupportForBatchCreateAttributes(): bool;
10311030

1031+
/**
1032+
* Is spatial attributes supported?
1033+
*
1034+
* @return bool
1035+
*/
1036+
abstract public function getSupportForSpatialAttributes(): bool;
1037+
1038+
/**
1039+
* Does the adapter support null values in spatial indexes?
1040+
*
1041+
* @return bool
1042+
*/
1043+
abstract public function getSupportForSpatialIndexNull(): bool;
1044+
1045+
/**
1046+
* Does the adapter support order attribute in spatial indexes?
1047+
*
1048+
* @return bool
1049+
*/
1050+
abstract public function getSupportForSpatialIndexOrder(): bool;
1051+
1052+
/**
1053+
* Does the adapter includes boundary during spatial contains?
1054+
*
1055+
* @return bool
1056+
*/
1057+
abstract public function getSupportForBoundaryInclusiveContains(): bool;
1058+
10321059
/**
10331060
* Get current attribute count from collection document
10341061
*

0 commit comments

Comments
 (0)