浏览代码

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'
ovidiupruteanu 12 年之前
父节点
当前提交
56a3f093a1
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      lib/Cake/Model/Datasource/Database/Sqlserver.php

+ 3 - 2
lib/Cake/Model/Datasource/Database/Sqlserver.php

@@ -201,7 +201,8 @@ class Sqlserver extends DboSource {
 			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,
@@ -212,7 +213,7 @@ class Sqlserver extends DboSource {
 				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));