Added support for Laravel 12 (#36)
This commit is contained in:
+1
-1
@@ -52,7 +52,7 @@ class Connection extends BaseConnection
|
||||
/** @inheritDoc */
|
||||
protected function getDefaultSchemaGrammar()
|
||||
{
|
||||
return new SchemaGrammar();
|
||||
return new SchemaGrammar($this);
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
Reference in New Issue
Block a user