Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/Database/Adapter/MariaDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function createCollection(string $name, array $attributes = [], array $in

$collection = "
CREATE TABLE {$this->getSQLTable($id)} (
_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
_uid VARCHAR(255) NOT NULL,
_createdAt DATETIME(3) DEFAULT NULL,
_updatedAt DATETIME(3) DEFAULT NULL,
Expand Down Expand Up @@ -186,7 +186,7 @@ public function createCollection(string $name, array $attributes = [], array $in

$permissions = "
CREATE TABLE {$this->getSQLTable($id . '_perms')} (
_id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
_type VARCHAR(12) NOT NULL,
_permission VARCHAR(255) NOT NULL,
_document VARCHAR(255) NOT NULL,
Expand Down
12 changes: 5 additions & 7 deletions src/Database/Adapter/Postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,13 @@ public function createCollection(string $name, array $attributes = [], array $in
$sqlTenant = $this->sharedTables ? '_tenant INTEGER DEFAULT NULL,' : '';
$collection = "
CREATE TABLE {$this->getSQLTable($id)} (
_id SERIAL NOT NULL,
_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
_uid VARCHAR(255) NOT NULL,
" . $sqlTenant . "
\"_createdAt\" TIMESTAMP(3) DEFAULT NULL,
\"_updatedAt\" TIMESTAMP(3) DEFAULT NULL,
_permissions TEXT DEFAULT NULL,
" . \implode(' ', $attributeStrings) . "
PRIMARY KEY (_id)
_permissions TEXT DEFAULT NULL
);
";

Expand All @@ -262,13 +261,12 @@ public function createCollection(string $name, array $attributes = [], array $in

$permissions = "
CREATE TABLE {$this->getSQLTable($id . '_perms')} (
_id SERIAL NOT NULL,
_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
_tenant INTEGER DEFAULT NULL,
_type VARCHAR(12) NOT NULL,
_permission VARCHAR(255) NOT NULL,
_document VARCHAR(255) NOT NULL,
PRIMARY KEY (_id)
);
_document VARCHAR(255) NOT NULL
);
";

if ($this->sharedTables) {
Expand Down
25 changes: 25 additions & 0 deletions tests/e2e/Adapter/Scopes/DocumentTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@

trait DocumentTests
{
public function testBigintSequence(): void
{
/** @var Database $database */
$database = static::getDatabase();

$database->createCollection(__FUNCTION__);

$sequence = 5_000_000_000_000_000;

$document = $database->createDocument(__FUNCTION__, new Document([
'$sequence' => (string)$sequence,
'$permissions' => [
Permission::read(Role::any()),
],
]));

$this->assertEquals((string)$sequence, $document->getSequence());

$document = $database->getDocument(__FUNCTION__, $document->getId());
$this->assertEquals((string)$sequence, $document->getSequence());

$document = $database->findOne(__FUNCTION__, [Query::equal('$sequence', [(string)$sequence])]);
$this->assertEquals((string)$sequence, $document->getSequence());
}

public function testCreateDocument(): Document
{
/** @var Database $database */
Expand Down