fix(sqlserver): preserve database-qualified editing targets
This commit is contained in:
1 parent
9d7f87feb8
commit
b89e0079a5
4 files changed
+132
-15
No files matched your search
@@ -71,17 +71,12 @@ pub fn qualified_table_name(database_type: Option<DatabaseType>, schema: Option<
|
||||
quote_table_identifier(database_type, table_name)
|
||||
}
|
||||
|
||||
/// Like `qualified_table_name`, but prefixes a Doris/StarRocks external
|
||||
/// catalog (`<catalog>.<database>.<table>`) when `catalog` is present,
|
||||
/// non-empty, and not the engine's `internal` catalog. The middle segment is
|
||||
/// the database — Doris/StarRocks have no separate schema concept, so
|
||||
/// `schema` is only used when a caller passes it that way; otherwise `database`
|
||||
/// fills the middle slot. When neither is set the name degrades to the 2-part
|
||||
/// `<catalog>.<table>` form. The `internal` guard is defensive — built-in
|
||||
/// catalog tables never carry a catalog in the first place (the sidebar routes
|
||||
/// them through the standard path), so this only ever prefixes genuine
|
||||
/// external catalogs. Other engines ignore `catalog` (they have no 3-part
|
||||
/// catalog naming).
|
||||
/// Like `qualified_table_name`, but also supports 3-part names for SQL Server
|
||||
/// (`<database>.<schema>.<table>`) and Doris/StarRocks external catalogs
|
||||
/// (`<catalog>.<database>.<table>`). SQL parsing stores the first segment of a
|
||||
/// 3-part source in `catalog`; for SQL Server that segment is its database.
|
||||
/// Doris/StarRocks use `schema` as the middle segment when present, otherwise
|
||||
/// `database`, and ignore their built-in `internal` catalog.
|
||||
pub fn qualified_table_name_with_catalog(
|
||||
database_type: Option<DatabaseType>,
|
||||
catalog: Option<&str>,
|
||||
@@ -89,9 +84,13 @@ pub fn qualified_table_name_with_catalog(
|
||||
database: Option<&str>,
|
||||
table_name: &str,
|
||||
) -> String {
|
||||
let catalog = catalog.map(str::trim).filter(|catalog| !catalog.is_empty() && *catalog != "internal");
|
||||
let catalog = catalog.map(str::trim).filter(|catalog| !catalog.is_empty());
|
||||
match (catalog, database_type) {
|
||||
(Some(catalog), Some(DatabaseType::Doris | DatabaseType::StarRocks)) => {
|
||||
(Some(database), Some(DatabaseType::SqlServer)) => {
|
||||
let table = qualified_table_name(database_type, schema, table_name);
|
||||
format!("{}.{}", quote_table_identifier(database_type, database), table)
|
||||
}
|
||||
(Some(catalog), Some(DatabaseType::Doris | DatabaseType::StarRocks)) if catalog != "internal" => {
|
||||
let middle = schema
|
||||
.map(str::trim)
|
||||
.filter(|schema| !schema.is_empty())
|
||||
|
||||
Reference in new issue
Block a user