Support changing and creating vector columns
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
This commit is contained in:
parent
38ef3239cb
commit
9691b95ad8
@ -213,6 +213,19 @@ class Compatibility
|
||||
return $dbi->isMariaDB() && $dbi->getVersion() >= 100700; // 10.7.0
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the database supports VECTOR data type
|
||||
*
|
||||
* @return bool true if VECTOR is supported
|
||||
*/
|
||||
public static function isVectorSupported(DatabaseInterface $dbi): bool
|
||||
{
|
||||
// @see: https://mariadb.com/docs/release-notes/community-server/old-releases/mariadb-11-7-rolling-releases/mariadb-11-7-1-release-notes#vectors
|
||||
// @see: https://dev.mysql.com/doc/relnotes/mysql/9.0/en/news-9-0-0.html#mysqld-9-0-0-vectors
|
||||
return $dbi->isMariaDB() && $dbi->getVersion() >= 110701 || // 11.7.1
|
||||
$dbi->isMySql() && $dbi->getVersion() >= 90000; // 9.0.0
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the database server supports virtual columns
|
||||
*/
|
||||
|
||||
@ -775,6 +775,7 @@ class Types
|
||||
$isMariaDB = $this->dbi->isMariaDB();
|
||||
$serverVersion = $this->dbi->getVersion();
|
||||
$isUUIDSupported = Compatibility::isUUIDSupported($this->dbi);
|
||||
$isVectorSupported = Compatibility::isVectorSupported($this->dbi);
|
||||
|
||||
// most used types
|
||||
$ret = [
|
||||
@ -862,6 +863,10 @@ class Types
|
||||
$ret['UUID'] = ['UUID'];
|
||||
}
|
||||
|
||||
if ($isVectorSupported) {
|
||||
$ret['VECTOR'] = ['VECTOR'];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
@ -51,6 +51,33 @@ class CompatibilityTest extends TestCase
|
||||
self::assertSame($expected, Compatibility::isUUIDSupported($dbiStub));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, array{bool, bool, int}>
|
||||
*/
|
||||
public static function providerForTestIsVectorSupported(): array
|
||||
{
|
||||
return [
|
||||
'MySQL 8.99.99' => [false, false, 89999],
|
||||
'MySQL 9.0.0' => [false, false, 90000],
|
||||
'MariaDB 11.6.99' => [false, true, 110699],
|
||||
'MariaDB 11.7.1' => [true, true, 110701],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForTestIsVectorSupported
|
||||
*/
|
||||
public function testIsVectorSupported(bool $expected, bool $isMariaDb, int $version): void
|
||||
{
|
||||
$dbiStub = $this->createStub(DatabaseInterface::class);
|
||||
|
||||
$dbiStub->method('isMariaDB')->willReturn($isMariaDb);
|
||||
$dbiStub->method('getVersion')->willReturn($version);
|
||||
|
||||
self::assertSame($expected, Compatibility::isVectorSupported($dbiStub));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, array{bool, bool, int}>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user