Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many to One issue - invalid relation type #354

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
stopOnFailure="true">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
Expand Down
4 changes: 4 additions & 0 deletions src/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -3550,6 +3550,10 @@ private function updateDocumentRelationships(Document $collection, Document $old
$document->setAttribute($key, $value->getId());
} elseif (\is_null($value)) {
break;
} elseif(empty($value)){
var_dump('I am an empty array Is I think it is ok to throw an exeption');
throw new DatabaseException('Invalid value for relationship');

} else {
throw new DatabaseException('Invalid value for relationship');
}
Expand Down
18 changes: 18 additions & 0 deletions tests/Database/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -6799,6 +6799,24 @@ public function testManyToOneOneWayRelationship(): void
$review5 = static::getDatabase()->getDocument('review', 'review5');
$this->assertEquals('Movie 5', $review5->getAttribute('movie')->getAttribute('name'));


// Todo: fix this is failing
static::getDatabase()->updateDocument('review', $review5->getId(), new Document([
'$id' => 'review5',
'$permissions' => [
Permission::read(Role::any()),
Permission::update(Role::any()),
Permission::delete(Role::any()),
],
'name' => 'Review 5',
'movie' => [], //
]));


$this->assertEquals(true, false);



// Update document with new related document
static::getDatabase()->updateDocument(
'review',
Expand Down
Loading