Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
bf740e2
fix validator namespaces
lohanidamodar Jul 18, 2023
3bf21fd
Switch v2 branch
Meldiron Oct 4, 2023
ffa1b71
Merge branch 'main' into feat-framework-v2
Meldiron Oct 5, 2023
1d4ab3d
Fix lockfile after merge
Meldiron Oct 5, 2023
41134cc
Make authorization per-instance
Meldiron Oct 19, 2023
a8bec8b
Fix incorrect Auth instance in tests
Meldiron Oct 19, 2023
fefad52
Fix tests
Meldiron Oct 19, 2023
c14be0f
PR review changes
Meldiron Jan 3, 2024
00c1553
Refactor auth message and action
Meldiron Jan 3, 2024
c2f3585
Fix test
Meldiron Jan 3, 2024
dd4331d
Merge pull request #375 from utopia-php/feat-authorization-v2-result
Meldiron Jan 3, 2024
59588d6
Make auth validator follow adapter
Meldiron Jan 24, 2024
e79ddd1
Upgrade dependencies
Meldiron Jan 24, 2024
8ce9213
Merge remote-tracking branch 'origin/main' into feat-framework-v2
Meldiron Jan 24, 2024
f55b13d
Fix tests
Meldiron Jan 24, 2024
26704cb
PR review changes
Meldiron Jan 25, 2024
95b4d71
Merge remote-tracking branch 'origin/feat-framework-v2' into feat-aut…
Meldiron Jan 25, 2024
efd5d1e
Update lockfile
Meldiron Jan 25, 2024
f0dc793
CI/CD fixes
Meldiron Jan 25, 2024
597a9ab
Fix all tests 🎉
Meldiron Jan 25, 2024
6f8b4a7
Remove validation exception
Meldiron Jan 25, 2024
b64caf4
Merge pull request #343 from utopia-php/feat-authorization-v2
abnegate Jan 25, 2024
fa6afda
Merge remote-tracking branch 'origin/main' into feat-framework-v2
Meldiron Feb 22, 2024
6dd6562
Post-merge fixes
Meldiron Feb 22, 2024
3465bc5
Add method for coroutine-style to wipe previous transformations state
Meldiron Feb 27, 2024
79fd579
Improve clear transformation
Meldiron Feb 27, 2024
c4727ee
Merge remote-tracking branch 'origin/main' into feat-framework-v2
Meldiron Mar 7, 2024
73fb443
Resolve framework V2 issues
Meldiron Mar 7, 2024
bdd9140
Add new method
Meldiron Mar 7, 2024
b0010c4
composer.lock
fogelito Apr 17, 2024
b3f7843
Merge branch 'main' of github.com:utopia-php/database into feat-frame…
fogelito Apr 17, 2024
0645d85
composer.lock
fogelito Apr 17, 2024
a0bd330
Merge branch 'main' of github.com:utopia-php/database into feat-frame…
fogelito Apr 18, 2024
6b8264a
updateRelationship
fogelito Apr 18, 2024
0d7b914
Remove Proxy files
fogelito Apr 19, 2024
2ed8b6b
Merge branch 'main' of github.com:utopia-php/database into feat-frame…
fogelito May 9, 2024
04abd91
pull main
fogelito May 9, 2024
f53d63b
lint
fogelito May 9, 2024
e29e62b
Merge branch 'refs/heads/main' into feat-framework-v2
byawitz Jun 6, 2024
5b0d6ba
chore: Updating composer.lock
byawitz Jun 6, 2024
0b45a0d
Merge branch 'refs/heads/main' into feat-framework-v2
byawitz Jul 19, 2024
964bfa2
chore: merge
byawitz Jul 19, 2024
ab01fa3
chore: codeql
byawitz Jul 19, 2024
9ddf91a
tests: Adjusting to new authorization
byawitz Jul 19, 2024
36720e8
chore: versions upgrade
byawitz Aug 9, 2024
a170c08
Merge branch 'main' into feat-framework-v2
byawitz Sep 4, 2024
a25e63e
chore: merge
byawitz Sep 4, 2024
8dfdf8d
chore: format
byawitz Sep 4, 2024
bfd1168
chore: Updating composer.lock
byawitz Sep 4, 2024
d70eb76
chore: format
byawitz Sep 4, 2024
e2bf86a
chore: Updating composer.lock
byawitz Sep 5, 2024
bb2a687
chore: updating packages
byawitz Sep 5, 2024
1e97fc8
Merge pull request #376 from utopia-php/feat-framework-v2
christyjacob4 Sep 5, 2024
170f8d5
Initial Push for Batch Deletes
PineappleIOnic Sep 10, 2024
20a0467
Fix non-quoted newKey in MariaDB and add newKey filtering for postgres
PineappleIOnic Sep 10, 2024
c32d6ea
Merge pull request #448 from utopia-php/fix-add-escapes-for-rename
abnegate Sep 10, 2024
79e65da
Update src/Database/Adapter/MariaDB.php
PineappleIOnic Sep 10, 2024
b079870
Address comments, add MongoDB and Postgres Support
PineappleIOnic Sep 17, 2024
a931aab
Make event test the last test
PineappleIOnic Sep 17, 2024
4f3e91e
Run Linter
PineappleIOnic Sep 17, 2024
0fe42d5
Merge branch 'main' into feat-batch-delete
PineappleIOnic Sep 17, 2024
c3115b5
Update Authorisation Validator
PineappleIOnic Sep 17, 2024
1b3d2e9
Make findOne return empty document instead of false when no matches a…
PineappleIOnic Sep 17, 2024
0ad2eb1
Merge pull request #449 from utopia-php/feat-find-one-update
stnguyen90 Sep 18, 2024
ddca761
Add get collection size data method
PineappleIOnic Sep 23, 2024
25bbfd4
Run Linter
PineappleIOnic Sep 23, 2024
79da9b5
Address comments
PineappleIOnic Sep 23, 2024
496b574
Get tests working for MariaDB
PineappleIOnic Sep 23, 2024
96a8d60
Sync with 0.53.x branch version
PineappleIOnic Sep 27, 2024
04d8015
Use ID based deletion, add more tests
PineappleIOnic Oct 1, 2024
87a6e3a
Linter and CodeQL
PineappleIOnic Oct 1, 2024
22abde7
CodeQL
PineappleIOnic Oct 1, 2024
19e6029
Continue to add more tests
PineappleIOnic Oct 2, 2024
d3264dc
Fix Cascade
PineappleIOnic Oct 2, 2024
1241b0a
Run Linter
PineappleIOnic Oct 2, 2024
becd847
Fix sizeOfDisk tests
PineappleIOnic Oct 4, 2024
dd61208
Merge pull request #450 from utopia-php/feat-get-collection-size-data
eldadfux Oct 4, 2024
e6eae09
Remove unnecessary cleanup
PineappleIOnic Oct 4, 2024
f1a9eb5
Disable debug in compose file
PineappleIOnic Oct 4, 2024
794b845
Sync findOne style from 0.53 to main
PineappleIOnic Oct 7, 2024
87ed4f4
Merge branch '0.53.x'
byawitz Oct 7, 2024
ce3c916
chore: merge
byawitz Oct 7, 2024
e5ace79
chore: package update
byawitz Oct 7, 2024
b2e2681
chore: format
byawitz Oct 7, 2024
ed5227c
fix: review
byawitz Oct 7, 2024
6f44079
Merge pull request #457 from utopia-php/chore-packages-upgrade
christyjacob4 Oct 7, 2024
f979e2f
Merge pull request #454 from utopia-php/fix-findone-style
abnegate Oct 8, 2024
09a217f
Continue work on batch updates
PineappleIOnic Oct 9, 2024
dbe77e9
Add more tests
PineappleIOnic Oct 10, 2024
c75b4bf
Remove debug flag in compose file
PineappleIOnic Oct 10, 2024
4121f7f
Run Linter
PineappleIOnic Oct 10, 2024
5e819e8
Get updateDocuments working for all adapters, add tests
PineappleIOnic Oct 14, 2024
3acb215
Fix PHPStan issues
PineappleIOnic Oct 14, 2024
e60df0d
Get document permissions working
PineappleIOnic Oct 14, 2024
2be9b33
Continue work on permissions
PineappleIOnic Oct 14, 2024
35201c0
Add Permission Update code for MariaDB
PineappleIOnic Oct 15, 2024
d058140
Get permission security working with tests apart from mongo
PineappleIOnic Oct 16, 2024
31d6bea
Fix Mongo and phpstan issues
PineappleIOnic Oct 16, 2024
161b561
Run Linter
PineappleIOnic Oct 16, 2024
66e0736
Use new event for bulk delete
PineappleIOnic Oct 16, 2024
51e39ac
Add relationship tests, return amount of documents modified
PineappleIOnic Oct 17, 2024
619a7a2
Run Linter, Address PHPStan
PineappleIOnic Oct 17, 2024
ce1f15e
Fix Affected count
PineappleIOnic Oct 17, 2024
20ea1fa
Fix SQLite because it doesn't support relationships
PineappleIOnic Oct 17, 2024
4523393
Phpstan
PineappleIOnic Oct 17, 2024
0374d6e
Address comments
PineappleIOnic Oct 18, 2024
a71a7c9
Get relationship tests working
PineappleIOnic Oct 18, 2024
d34b44d
Address comments
PineappleIOnic Oct 18, 2024
afd0d9c
Run Linter
PineappleIOnic Oct 18, 2024
6e2b974
Address comments, work on fixes for permissions
PineappleIOnic Oct 18, 2024
9e603ec
Fix permissions removal query
abnegate Oct 18, 2024
0223205
Merge remote-tracking branch 'origin/main' into feat-batch-update
abnegate Oct 18, 2024
935c937
Remove debug
abnegate Oct 18, 2024
36758c8
Revert "Fix permissions removal query"
abnegate Oct 18, 2024
a65da29
Fix mongoDB attempting to delete an empty array of documents
PineappleIOnic Oct 28, 2024
b3cab3b
Move empty affected document check to database.php
PineappleIOnic Oct 28, 2024
adacd14
Fix removing permissions SQL
PineappleIOnic Nov 1, 2024
a1a5f53
Address comments
PineappleIOnic Nov 1, 2024
0201e89
Merge pull request #462 from utopia-php/feat-batch-update
abnegate Nov 1, 2024
82eecce
Merge branch 'main' into feat-batch-delete
PineappleIOnic Nov 1, 2024
53c4ff7
Merge pull request #447 from utopia-php/feat-batch-delete
abnegate Nov 1, 2024
af2d2f4
Revert "Merge pull request #376 from utopia-php/feat-framework-v2"
abnegate Jan 13, 2025
169977b
Fix test refs
abnegate Jan 13, 2025
0cbdb24
Update cache
abnegate Jan 13, 2025
1c0edeb
Update framework
abnegate Jan 13, 2025
15c0b00
Update test auth refs
abnegate Jan 13, 2025
7c4237e
Format
abnegate Jan 13, 2025
2626a74
Sync database
abnegate Jan 13, 2025
1f4b7df
Merge remote-tracking branch 'origin/0.53.x' into chore-revert-framew…
abnegate Jan 13, 2025
b64c714
Merge pull request #502 from utopia-php/chore-revert-framework-v2
abnegate Jan 13, 2025
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
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Database/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ abstract public function sum(string $collection, string $attribute, array $queri
abstract public function count(string $collection, array $queries = [], ?int $max = null): int;

/**
* Get Collection Size
* Get Collection Size of the raw data
*
* @param string $collection
* @return int
Expand Down Expand Up @@ -972,7 +972,7 @@ protected function getAttributeSelections(array $queries): array
*/
public function filter(string $value): string
{
$value = \preg_replace("/[^A-Za-z0-9\_\-]/", '', $value);
$value = \preg_replace("/[^A-Za-z0-9_\-]/", '', $value);

if (\is_null($value)) {
throw new DatabaseException('Failed to filter key');
Expand Down
1 change: 1 addition & 0 deletions src/Database/Adapter/MariaDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -2481,4 +2481,5 @@ public function getSupportForSchemaAttributes(): bool
{
return true;
}

}
25 changes: 13 additions & 12 deletions src/Database/Adapter/Mongo.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,18 @@ public function listCollections(): array
}

/**
* Get Collection Size
* Get Collection Size on disk
* @param string $collection
* @return int
* @throws DatabaseException
*/
public function getSizeOfCollectionOnDisk(string $collection): int
{
return $this->getSizeOfCollection($collection);
}

/**
* Get Collection Size of raw data
* @param string $collection
* @return int
* @throws DatabaseException
Expand Down Expand Up @@ -311,17 +322,6 @@ public function getSizeOfCollection(string $collection): int
}
}

/**
* Get Collection Size on disk
* @param string $collection
* @return int
* @throws DatabaseException
*/
public function getSizeOfCollectionOnDisk(string $collection): int
{
return $this->getSizeOfCollection($collection);
}

/**
* Delete Collection
*
Expand Down Expand Up @@ -1962,4 +1962,5 @@ public function getSchemaAttributes(string $collection): array
{
return [];
}

}
35 changes: 29 additions & 6 deletions src/Database/Adapter/Postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,12 @@ public function createCollection(string $name, array $attributes = [], array $in
}

/**
* Get Collection Size
* Get Collection Size on disk
* @param string $collection
* @return int
* @throws DatabaseException
*
*/
public function getSizeOfCollection(string $collection): int
public function getSizeOfCollectionOnDisk(string $collection): int
{
$collection = $this->filter($collection);
$name = $this->getSQLTable($collection);
Expand Down Expand Up @@ -333,14 +332,38 @@ public function getSizeOfCollection(string $collection): int
}

/**
* Get Collection Size on disk
* Get Collection Size of raw data
* @param string $collection
* @return int
* @throws DatabaseException
*
*/
public function getSizeOfCollectionOnDisk(string $collection): int
public function getSizeOfCollection(string $collection): int
{
return $this->getSizeOfCollection($collection);
$collection = $this->filter($collection);
$name = $this->getSQLTable($collection);
$permissions = $this->getSQLTable($collection . '_perms');

$collectionSize = $this->getPDO()->prepare("
SELECT pg_relation_size(:name);
");

$permissionsSize = $this->getPDO()->prepare("
SELECT pg_relation_size(:permissions);
");

$collectionSize->bindParam(':name', $name);
$permissionsSize->bindParam(':permissions', $permissions);

try {
$collectionSize->execute();
$permissionsSize->execute();
$size = $collectionSize->fetchColumn() + $permissionsSize->fetchColumn();
} catch (PDOException $e) {
throw new DatabaseException('Failed to get collection size: ' . $e->getMessage());
}

return $size;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Database/Adapter/SQLite.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ public function createCollection(string $name, array $attributes = [], array $in
return true;
}


/**
* Get Collection Size
* Get Collection Size of raw data
* @param string $collection
* @return int
* @throws DatabaseException
Expand Down
20 changes: 10 additions & 10 deletions src/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ public function deleteCollection(string $id): bool
$relationships = \array_filter(
$collection->getAttribute('attributes'),
fn ($attribute) =>
$attribute->getAttribute('type') === Database::VAR_RELATIONSHIP
$attribute->getAttribute('type') === Database::VAR_RELATIONSHIP
);

foreach ($relationships as $relationship) {
Expand Down Expand Up @@ -3002,7 +3002,7 @@ public function getDocument(string $collection, string $id, array $queries = [],
$relationships = \array_filter(
$collection->getAttribute('attributes', []),
fn ($attribute) =>
$attribute['type'] === Database::VAR_RELATIONSHIP
$attribute['type'] === Database::VAR_RELATIONSHIP
);

$hasTwoWayRelationship = false;
Expand Down Expand Up @@ -3118,8 +3118,8 @@ private function populateDocumentRelationships(Document $collection, Document $d
// collection as an existing relationship, but a different two-way key (the third condition),
// or the same two-way key as an existing relationship, but a different key (the fourth condition).
$transitive = (($existingKey === $twoWayKey
&& $existingCollection === $relatedCollection->getId()
&& $existingSide !== $side)
&& $existingCollection === $relatedCollection->getId()
&& $existingSide !== $side)
|| ($existingTwoWayKey === $key
&& $existingRelatedCollection === $collection->getId()
&& $existingSide !== $side)
Expand Down Expand Up @@ -3456,7 +3456,7 @@ private function createDocumentRelationships(Document $collection, Document $doc
$relationships = \array_filter(
$attributes,
fn ($attribute) =>
$attribute['type'] === Database::VAR_RELATIONSHIP
$attribute['type'] === Database::VAR_RELATIONSHIP
);

$stackCount = count($this->relationshipWriteStack);
Expand Down Expand Up @@ -4838,8 +4838,8 @@ private function deleteDocumentRelationships(Document $collection, Document $doc
// collection as an existing relationship, but a different two-way key (the third condition),
// or the same two-way key as an existing relationship, but a different key (the fourth condition).
$transitive = (($existingKey === $twoWayKey
&& $existingCollection === $relatedCollection->getId()
&& $existingSide !== $side)
&& $existingCollection === $relatedCollection->getId()
&& $existingSide !== $side)
|| ($existingTwoWayKey === $key
&& $existingRelatedCollection === $collection->getId()
&& $existingSide !== $side)
Expand Down Expand Up @@ -5694,13 +5694,13 @@ public function decode(Document $collection, Document $document, array $selectio
$attributes = \array_filter(
$collection->getAttribute('attributes', []),
fn ($attribute) =>
$attribute['type'] !== self::VAR_RELATIONSHIP
$attribute['type'] !== self::VAR_RELATIONSHIP
);

$relationships = \array_filter(
$collection->getAttribute('attributes', []),
fn ($attribute) =>
$attribute['type'] === self::VAR_RELATIONSHIP
$attribute['type'] === self::VAR_RELATIONSHIP
);

foreach ($relationships as $relationship) {
Expand Down Expand Up @@ -6021,7 +6021,7 @@ private function purgeRelatedDocuments(Document $collection, string $id): void
$relationships = \array_filter(
$collection->getAttribute('attributes', []),
fn ($attribute) =>
$attribute['type'] === Database::VAR_RELATIONSHIP
$attribute['type'] === Database::VAR_RELATIONSHIP
);

if (empty($relationships)) {
Expand Down
36 changes: 18 additions & 18 deletions tests/e2e/Adapter/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -6994,8 +6994,8 @@ public function testOneToOneOneWayRelationship(): void
$person1->setAttribute(
'library',
$person1
->getAttribute('library')
->setAttribute('name', 'Library 1 Updated')
->getAttribute('library')
->setAttribute('name', 'Library 1 Updated')
)
);

Expand Down Expand Up @@ -7466,8 +7466,8 @@ public function testOneToOneTwoWayRelationship(): void
$country1->setAttribute(
'city',
$country1
->getAttribute('city')
->setAttribute('name', 'City 1 Updated')
->getAttribute('city')
->setAttribute('name', 'City 1 Updated')
)
);

Expand All @@ -7482,8 +7482,8 @@ public function testOneToOneTwoWayRelationship(): void
$city2->setAttribute(
'country',
$city2
->getAttribute('country')
->setAttribute('name', 'Country 2 Updated')
->getAttribute('country')
->setAttribute('name', 'Country 2 Updated')
)
);

Expand Down Expand Up @@ -8485,8 +8485,8 @@ public function testOneToManyTwoWayRelationship(): void
$account2->setAttribute(
'customer',
$account2
->getAttribute('customer')
->setAttribute('name', 'Customer 2 Updated')
->getAttribute('customer')
->setAttribute('name', 'Customer 2 Updated')
)
);

Expand Down Expand Up @@ -12398,19 +12398,19 @@ public function testExceedMaxDepthOneToMany(): void
$level1Collection,
'level1',
$level1
->setAttribute($level2Collection, [new Document([
'$id' => 'level2new',
$level3Collection => [
[
'$id' => 'level3new',
$level4Collection => [
[
'$id' => 'level4new',
->setAttribute($level2Collection, [new Document([
'$id' => 'level2new',
$level3Collection => [
[
'$id' => 'level3new',
$level4Collection => [
[
'$id' => 'level4new',
],
],
],
],
],
])])
])])
);
$this->assertEquals(1, count($level1[$level2Collection]));
$this->assertEquals('level2new', $level1[$level2Collection][0]->getId());
Expand Down
Loading