Added support for Laravel 12 (#36)

This commit is contained in:
Denis Glushkov
2025-02-25 11:52:00 +05:00
parent 67caa69f66
commit e919c58330
4 changed files with 11 additions and 9 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ class Connection extends BaseConnection
/** @inheritDoc */
protected function getDefaultSchemaGrammar()
{
return new SchemaGrammar();
return new SchemaGrammar($this);
}
/** @inheritDoc */
+1 -1
View File
@@ -12,7 +12,7 @@ class SchemaBuilder extends BaseBuilder
public function hasTable($table): bool
{
return count($this->connection->select(
$this->grammar->compileTableExists(), [$this->connection->getDatabaseName(), $table]
$this->grammar->compileTableExists($this->connection->getDatabaseName(), $table)
)) > 0;
}
}
+9 -7
View File
@@ -11,13 +11,16 @@ use Illuminate\Support\Fluent;
class SchemaGrammar extends Grammar
{
/**
* Compile the query to determine the list of tables.
* Compile the query to determine if the given table exists.
*
* @param string|null $schema
* @param string $table
* @return string
*/
public function compileTableExists(): string
public function compileTableExists($schema, $table): string
{
return "select * from system.tables where database = :0 and name = :1";
return "select * from system.tables where database = " . $this->quoteString($schema)
. " and name = " . $this->quoteString($table);
}
/**
@@ -25,10 +28,9 @@ class SchemaGrammar extends Grammar
*
* @param Blueprint $blueprint
* @param Fluent $command
* @param Connection $connection
* @return array
* @return string
*/
public function compileCreate(Blueprint $blueprint, Fluent $command, Connection $connection): array
public function compileCreate(Blueprint $blueprint, Fluent $command)
{
$sql = "CREATE TABLE :table (
:columns
@@ -43,7 +45,7 @@ class SchemaGrammar extends Grammar
];
$sql = str_replace(array_keys($bindings), array_values($bindings), $sql);
return [$sql];
return $sql;
}
/**
Regular → Executable
View File