提交 57f914df authored 作者: Thomas Mueller's avatar Thomas Mueller

DatabaseMetaData.getColumns: there is a typo in the JDBC specification, so that…

DatabaseMetaData.getColumns: there is a typo in the JDBC specification, so that the column #19 is named SCOPE_CATLOG instead of SCOPE_CATALOG. For compatibility with the specification, this column is now also named SCOPE_CATLOG in H2. A new column named SCOPE_CATALOG is appended as column #24. Please note that MySQL only supports SCOPE_CATALOG, while other databases only support SCOPE_CATLOG.
上级 8fe5f794
......@@ -197,11 +197,13 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* <li>16 CHAR_OCTET_LENGTH (int) unused </li>
* <li>17 ORDINAL_POSITION (int) the column index (1,2,...) </li>
* <li>18 IS_NULLABLE (String) "NO" or "YES" </li>
* <li>19 SCOPE_CATALOG (String) always null </li>
* <li>19 SCOPE_CATLOG (String) always null
* (the typo is on purpose, for compatibility with the specification)</li>
* <li>20 SCOPE_SCHEMA (String) always null </li>
* <li>21 SCOPE_TABLE (String) always null </li>
* <li>22 SOURCE_DATA_TYPE (short) null </li>
* <li>23 IS_AUTOINCREMENT (String) "NO" or "YES" </li>
* <li>24 SCOPE_CATALOG (String) always null </li>
* </ul>
*
* @param catalogPattern null (to get all objects) or the catalog name
......@@ -244,11 +246,12 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
+ "CHARACTER_OCTET_LENGTH CHAR_OCTET_LENGTH, "
+ "ORDINAL_POSITION, "
+ "IS_NULLABLE IS_NULLABLE, "
+ "CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_CATALOG, "
+ "CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_CATLOG, "
+ "CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_SCHEMA, "
+ "CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_TABLE, "
+ "SOURCE_DATA_TYPE, "
+ "CASE WHEN SEQUENCE_NAME IS NULL THEN 'NO' ELSE 'YES' END IS_AUTOINCREMENT "
+ "CASE WHEN SEQUENCE_NAME IS NULL THEN 'NO' ELSE 'YES' END IS_AUTOINCREMENT, "
+ "CAST(SOURCE_DATA_TYPE AS VARCHAR) SCOPE_CATALOG "
+ "FROM INFORMATION_SCHEMA.COLUMNS "
+ "WHERE TABLE_CATALOG LIKE ? ESCAPE '\\' "
+ "AND TABLE_SCHEMA LIKE ? ESCAPE '\\' "
......
......@@ -664,14 +664,14 @@ public class TestMetaData extends TestBase {
assertResultSetOrdered(rs, new String[][] { { catalog, Constants.SCHEMA_MAIN, "TEST", "TABLE", "" } });
trace("getColumns");
rs = meta.getColumns(null, null, "TEST", null);
assertResultSetMeta(rs, 23, new String[] { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE",
assertResultSetMeta(rs, 24, new String[] { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE",
"TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS",
"COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH", "ORDINAL_POSITION",
"IS_NULLABLE", "SCOPE_CATALOG", "SCOPE_SCHEMA", "SCOPE_TABLE", "SOURCE_DATA_TYPE", "IS_AUTOINCREMENT" },
"IS_NULLABLE", "SCOPE_CATLOG", "SCOPE_SCHEMA", "SCOPE_TABLE", "SOURCE_DATA_TYPE", "IS_AUTOINCREMENT", "SCOPE_CATALOG" },
new int[] { Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER,
Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER,
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, Types.VARCHAR }, null, null);
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.SMALLINT, Types.VARCHAR, Types.VARCHAR }, null, null);
assertResultSetOrdered(rs,
new String[][] {
{ catalog, Constants.SCHEMA_MAIN, "TEST", "ID", "" + Types.INTEGER, "INTEGER", "10", "10", "0",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论