Skip to content

Commit

Permalink
Merge pull request #20 from wutherland/master
Browse files Browse the repository at this point in the history
Prevent postgreSQL lowercase column name and fix bugs of switch cases
  • Loading branch information
iberflow committed May 18, 2016
2 parents 5951ee9 + bb4a2d5 commit 1bc1b1c
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/Commands/MakeModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ protected function getSchemaTables()
case 'mysql':
$tables = \DB::select("SELECT table_name AS name FROM information_schema.tables WHERE table_type='BASE TABLE' AND table_schema = '" . env('DB_DATABASE') . "'" . $filterTablesWhere);
break;

case 'sqlsrv' || 'dblib':
$tables = \DB::select("SELECT table_name AS name FROM information_schema.tables WHERE table_type='BASE TABLE' AND table_catalog = '" . env('DB_DATABASE') . "'" . $filterTablesWhere);

case 'sqlsrv':
case 'dblib':
$tables = \DB::select("SELECT table_name AS name FROM information_schema.tables WHERE table_type='BASE TABLE' AND table_catalog = '" . env('DB_DATABASE') . "'" . $filterTablesWhere);
break;

case 'pgsql':
Expand Down Expand Up @@ -303,8 +304,9 @@ protected function getTableColumns($table)
case 'mysql':
$columns = \DB::select("SELECT COLUMN_NAME as `name` FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" . env("DB_DATABASE") . "' AND TABLE_NAME = '{$table}'");
break;

case 'sqlsrv' || 'dblib':

case 'sqlsrv':
case 'dblib':
$columns = \DB::select("SELECT COLUMN_NAME as 'name' FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_CATALOG = '" . env("DB_DATABASE") . "' AND TABLE_NAME = '{$table}'");
break;

Expand Down Expand Up @@ -335,9 +337,10 @@ protected function getTablePrimaryKey($table)
TABLE_NAME = '{$table}' AND
COLUMN_KEY = 'PRI'");
break;

case 'sqlsrv' || 'dblib':


case 'sqlsrv':
case 'dblib':

$primaryKeyResult = \DB::select(
"SELECT ku.COLUMN_NAME
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS tc
Expand All @@ -350,7 +353,7 @@ protected function getTablePrimaryKey($table)
case 'pgsql':

$primaryKeyResult = \DB::select(
"SELECT ku.COLUMN_NAME
"SELECT ku.COLUMN_NAME AS \"COLUMN_NAME\"
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS tc
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS ku
ON tc.CONSTRAINT_TYPE = 'PRIMARY KEY'
Expand Down

0 comments on commit 1bc1b1c

Please sign in to comment.