Merge pull request #356 from ericdagenais/itn/table-quotes
Fixes relation not found errors when dealing with table names that have uppercase characters
This commit is contained in:
commit
3b3d739e91
@ -260,7 +260,8 @@ func (client *Client) TableInfo(table string) (*Result, error) {
|
||||
if client.serverType == cockroachType {
|
||||
return client.query(statements.TableInfoCockroach)
|
||||
}
|
||||
return client.query(statements.TableInfo, table)
|
||||
schema, table := getSchemaAndTable(table)
|
||||
return client.query(statements.TableInfo, fmt.Sprintf(`"%s"."%s"`, schema, table))
|
||||
}
|
||||
|
||||
func (client *Client) TableIndexes(table string) (*Result, error) {
|
||||
|
@ -90,7 +90,7 @@ SELECT
|
||||
character_maximum_length,
|
||||
character_set_catalog,
|
||||
column_default,
|
||||
pg_catalog.col_description(($1::text || '.' || $2::text)::regclass::oid, ordinal_position) as comment
|
||||
pg_catalog.col_description(('"' || $1::text || '"."' || $2::text || '"')::regclass::oid, ordinal_position) as comment
|
||||
FROM
|
||||
information_schema.columns
|
||||
WHERE
|
||||
|
@ -865,6 +865,14 @@ function bindCurrentDatabaseMenu() {
|
||||
});
|
||||
}
|
||||
|
||||
function getQuotedSchemaTableName(table) {
|
||||
if (typeof table === "string" && table.indexOf(".") > -1) {
|
||||
var schemaTableComponents = table.split(".");
|
||||
return ['"', schemaTableComponents[0], '"."', schemaTableComponents[1], '"'].join('');
|
||||
}
|
||||
return table;
|
||||
}
|
||||
|
||||
function bindContextMenus() {
|
||||
bindTableHeaderMenu();
|
||||
bindCurrentDatabaseMenu();
|
||||
@ -878,7 +886,7 @@ function bindContextMenus() {
|
||||
scopes: "li.schema-table",
|
||||
onItem: function(context, e) {
|
||||
var el = $(e.target);
|
||||
var table = $(context[0]).data("id");
|
||||
var table = getQuotedSchemaTableName($(context[0]).data("id"));
|
||||
var action = el.data("action");
|
||||
performTableAction(table, action, el);
|
||||
}
|
||||
@ -891,7 +899,7 @@ function bindContextMenus() {
|
||||
scopes: "li.schema-view",
|
||||
onItem: function(context, e) {
|
||||
var el = $(e.target);
|
||||
var table = $(context[0]).data("id");
|
||||
var table = getQuotedSchemaTableName($(context[0]).data("id"));
|
||||
var action = el.data("action");
|
||||
performViewAction(table, action, el);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user