diff --git a/src/Query/Schema.php b/src/Query/Schema.php index 6a347b3..effa5dc 100644 --- a/src/Query/Schema.php +++ b/src/Query/Schema.php @@ -7,6 +7,7 @@ use Utopia\Query\Exception\ValidationException; use Utopia\Query\Schema\Column; use Utopia\Query\Schema\IndexType; +use Utopia\Query\Schema\Order; use Utopia\Query\Schema\Table; abstract class Schema @@ -414,7 +415,7 @@ protected function compileIndexColumns(Schema\Index $index): string if (isset($index->orders[$col])) { $order = \strtoupper($index->orders[$col]); - if ($order !== OrderDirection::Asc->value && $order !== OrderDirection::Desc->value) { + if (Order::tryFrom($order) === null) { throw new ValidationException('Invalid index order: ' . $index->orders[$col]); } $part .= ' ' . $order; diff --git a/src/Query/Schema/Order.php b/src/Query/Schema/Order.php new file mode 100644 index 0000000..4deb9fc --- /dev/null +++ b/src/Query/Schema/Order.php @@ -0,0 +1,9 @@ +assertSame('ASC', Order::Asc->value); + $this->assertSame('DESC', Order::Desc->value); + } +}