Skip to content
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 src/Database/Adapter/MariaDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function create(string $name): bool
return true;
}

$sql = "CREATE DATABASE `{$name}` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;";
$sql = "CREATE DATABASE IF NOT EXISTS `{$name}` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think COLLATE is different between Maria & MySQL


$sql = $this->trigger(Database::EVENT_DATABASE_CREATE, $sql);

Expand Down
40 changes: 40 additions & 0 deletions tests/e2e/Adapter/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2258,6 +2258,46 @@ public function testFind(): array
];
}

public function testOrderByNonEnglish(): void
{
Authorization::setRole(Role::any()->toString());

static::getDatabase()->createCollection('orderNonEnglish', permissions: [
Permission::create(Role::any()),
]);

$this->assertEquals(true, static::getDatabase()->createAttribute('orderNonEnglish', 'name', Database::VAR_STRING, 128, true));

static::getDatabase()->createDocument('orderNonEnglish', new Document([
'$permissions' => [
Permission::read(Role::any()),
],
'name' => 'Å',
]));

static::getDatabase()->createDocument('orderNonEnglish', new Document([
'$permissions' => [
Permission::read(Role::any()),
],
'name' => 'A',
]));

$documents = static::getDatabase()->find('orderNonEnglish', [
Query::orderAsc('name'),
]);

$this->assertEquals(2, count($documents));
$this->assertEquals('A', $documents[0]->getAttribute('name'));
$this->assertEquals('Å', $documents[1]->getAttribute('name'));

$documents = static::getDatabase()->find('orderNonEnglish', [
Query::orderDesc('name'),
]);

$this->assertEquals('Å', $documents[0]->getAttribute('name'));
$this->assertEquals('A', $documents[1]->getAttribute('name'));
}

public function testFindBasicChecks(): void
{
$documents = static::getDatabase()->find('movies');
Expand Down