From 23bf478fe7d95c75201433d0d03993176f0cfe20 Mon Sep 17 00:00:00 2001 From: BOIVIN Jonathan Date: Fri, 10 Dec 2021 15:37:55 +0100 Subject: [PATCH] fix(builder): fix getColumnListing --- src/Database/Schema/Builder.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Database/Schema/Builder.php b/src/Database/Schema/Builder.php index fc7eab6..d69f7e1 100644 --- a/src/Database/Schema/Builder.php +++ b/src/Database/Schema/Builder.php @@ -47,10 +47,26 @@ public function getColumnListing($table) { $sql = $this->grammar->compileColumnExists(); $database = $this->connection->getDatabaseName(); - $table = $this->connection->getTablePrefix().$table; - $results = $this->connection->select($sql, [$database, $table]); + $table = $this->connection->getTablePrefix() . $table; - return $this->connection->getPostProcessor()->processColumnListing($results); + $tableExploded = explode('.', $table); + + if (count($tableExploded) > 1) { + $database = $tableExploded[0]; + $table = $tableExploded[1]; + } + + $results = $this->connection->select($sql, [ + $database, + $table, + ]); + + $res = $this->connection->getPostProcessor() + ->processColumnListing($results); + + return array_values(array_map(function($r) { + return $r->column_name; + }, $res)); } /**