Sqlserver->describe failing for models with a schemaName

When models have a schemaName set it was searching for TABLE_NAME = 'schema_name.table_name'.
Instead it should search for TABLE_NAME = 'table_name' AND TABLE_SCHEMA = 'schema_name'
This commit is contained in:
ovidiupruteanu 2014-03-06 04:54:03 +02:00
parent 8b1e5e31c7
commit 56a3f093a1

View file

@ -201,7 +201,8 @@ class Sqlserver extends DboSource {
return $cache; return $cache;
} }
$fields = array(); $fields = array();
$table = $this->fullTableName($model, false); $table = $this->fullTableName($model, false, false);
$schema = $model->schemaName;
$cols = $this->_execute( $cols = $this->_execute(
"SELECT "SELECT
COLUMN_NAME as Field, COLUMN_NAME as Field,
@ -212,7 +213,7 @@ class Sqlserver extends DboSource {
COLUMNPROPERTY(OBJECT_ID('" . $table . "'), COLUMN_NAME, 'IsIdentity') as [Key], COLUMNPROPERTY(OBJECT_ID('" . $table . "'), COLUMN_NAME, 'IsIdentity') as [Key],
NUMERIC_SCALE as Size NUMERIC_SCALE as Size
FROM INFORMATION_SCHEMA.COLUMNS FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = '" . $table . "'" WHERE TABLE_NAME = '" . $table . "'".($schema?" AND TABLE_SCHEMA = '" . $schema . "'":'')
); );
if (!$cols) { if (!$cols) {
throw new CakeException(__d('cake_dev', 'Could not describe table for %s', $table)); throw new CakeException(__d('cake_dev', 'Could not describe table for %s', $table));