Skip to content

Commit

Permalink
Sqlserver->describe failing for models with a schemaName
Browse files Browse the repository at this point in the history
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'
  • Loading branch information
ovidiupruteanu committed Mar 6, 2014
1 parent 8b1e5e3 commit 56a3f09
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Cake/Model/Datasource/Database/Sqlserver.php
Expand Up @@ -201,7 +201,8 @@ public function describe($model) {
return $cache;
}
$fields = array();
$table = $this->fullTableName($model, false);
$table = $this->fullTableName($model, false, false);
$schema = $model->schemaName;
$cols = $this->_execute(
"SELECT
COLUMN_NAME as Field,
Expand All @@ -212,7 +213,7 @@ public function describe($model) {
COLUMNPROPERTY(OBJECT_ID('" . $table . "'), COLUMN_NAME, 'IsIdentity') as [Key],
NUMERIC_SCALE as Size
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = '" . $table . "'"
WHERE TABLE_NAME = '" . $table . "'".($schema?" AND TABLE_SCHEMA = '" . $schema . "'":'')
);
if (!$cols) {
throw new CakeException(__d('cake_dev', 'Could not describe table for %s', $table));
Expand Down

0 comments on commit 56a3f09

Please sign in to comment.