fix(phoenix): preserve schema in all table references

This commit is contained in:
jearhe authored and GitHub committed 2026-08-21 10:18:56 +08:00
1 parent e139f63953
commit f2e13922a2
18 files changed
+200 -9

No files matched your search

@@ -385,6 +385,10 @@ pub(crate) fn uses_connection_identifier_quote(
identifier_quote: Option<&str>,
) -> bool {
database_type == Some(DatabaseType::Kingbase)
// JDBC table-data requests carry the schema returned by DatabaseMetaData.
// Keep the JDBC identifier unquoted when no driver quote was reported, but
// still qualify the table with that schema.
|| database_type == Some(DatabaseType::Jdbc)
// Spanner is dual-dialect: GoogleSQL uses backticks, the PostgreSQL dialect uses
// double quotes, and only the connected agent knows which. Unconditional like
// Kingbase — when no quote was reported the callers fall back to
+38
View File
@@ -378,6 +378,44 @@ fn jdbc_non_tdengine_and_unscoped_tdengine_previews_remain_unqualified() {
}
}
#[test]
fn jdbc_table_data_qualifies_schema_without_forcing_identifier_quotes() {
assert_eq!(
build_table_data_select_sql(TableDataSelectSqlOptions {
database_type: Some(DatabaseType::Jdbc),
driver_profile: Some("phoenix".to_string()),
schema: Some("DEMO".to_string()),
table_name: "STUDENT".to_string(),
limit: Some(100),
..Default::default()
}),
"SELECT * FROM DEMO.STUDENT;"
);
assert_eq!(
build_table_data_select_sql(TableDataSelectSqlOptions {
database_type: Some(DatabaseType::Jdbc),
driver_profile: Some("phoenix".to_string()),
identifier_quote: Some("\"".to_string()),
schema: Some("MY_SCHEMA".to_string()),
table_name: "ORDER".to_string(),
limit: Some(100),
..Default::default()
}),
"SELECT * FROM \"MY_SCHEMA\".\"ORDER\";"
);
assert_eq!(
build_table_data_select_sql(TableDataSelectSqlOptions {
database_type: Some(DatabaseType::Jdbc),
driver_profile: Some("phoenix".to_string()),
schema: None,
table_name: "STUDENT".to_string(),
limit: Some(100),
..Default::default()
}),
"SELECT * FROM STUDENT;"
);
}
#[test]
fn builds_table_data_where_and_schema_queries() {
assert_eq!(