Skip to content

Commit

Permalink
fix: compatability with upcoming Laravel 11.30 release
Browse files Browse the repository at this point in the history
  • Loading branch information
tpetry committed Oct 30, 2024
1 parent a14719f commit 503c5e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Schema/BlueprintTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function varbit(string $column, ?int $length = null): ColumnDefinition
/**
* Create a new vector column on the table.
*/
public function vector($column, $dimensions): ColumnDefinition
public function vector($column, $dimensions = null): ColumnDefinition
{
return $this->addColumn('vector', $column, compact('dimensions'));
}
Expand Down
5 changes: 4 additions & 1 deletion src/Schema/Grammars/GrammarTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,10 @@ protected function typeVarbit(Fluent $column): string
*/
protected function typeVector(Fluent $column): string
{
return "vector({$column['dimensions']})";
return match ($column['dimensions']) {
null => 'vector',
default => "vector({$column['dimensions']})",
};
}

/**
Expand Down
12 changes: 9 additions & 3 deletions tests/Migration/TypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,17 @@ public function testVectorTypeIsSupported(): void

$this->getConnection()->statement('CREATE EXTENSION IF NOT EXISTS vector');
$queries = $this->runMigrations(
fnCreate: fn (Blueprint $table) => $table->vector('col', 1536),
fnChange: fn (Blueprint $table) => $table->vector('col', 1536)->change(),
fnCreate: function (Blueprint $table): void {
$table->vector('col1', 1536);
$table->vector('col2');
},
fnChange: function (Blueprint $table): void {
$table->vector('col1', 1536)->change();
$table->vector('col2')->change();
},
);

$this->assertEquals('create table "test" ("col" vector(1536) not null)', $queries[0]['query'] ?? null);
$this->assertEquals('create table "test" ("col1" vector(1536) not null, "col2" vector not null)', $queries[0]['query'] ?? null);
}

public function testXmlTypeIsSupported(): void
Expand Down

0 comments on commit 503c5e9

Please sign in to comment.