Skip to content

Commit

Permalink
fix(builder): fix getColumnListing
Browse files Browse the repository at this point in the history
  • Loading branch information
boivinj committed Dec 10, 2021
1 parent f8640dc commit 23bf478
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/Database/Schema/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down

0 comments on commit 23bf478

Please sign in to comment.