Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tables from Postgres datasource that are created under schemas with dashes are not listed #19743

Closed
thall opened this issue Oct 10, 2019 · 1 comment · Fixed by #45754
Closed

Comments

@thall
Copy link

thall commented Oct 10, 2019

What happened:
In the query tool when choosing from 'select table', tables that exists in schema test-schema doesnt shows up, even if search_path for that user contains test-schema.

What you expected to happen:
That the tables are shown

How to reproduce it (as minimally and precisely as possible):
Postgres setup

CREATE SCHEMA "test-schema";
ALTER ROLE youruser SET search_path = "test-schema","public";
CREATE TABLE "test-schema".test(id bigint);

Add postgres as datasource and connect with User: youruser and try to create a graph and see if test-table is listed in the drop down.

Anything else we need to know?:
Its possible to write "test-schema".test in the table-field, its just that it isn't shown.

Environment:

  • Grafana version: v5.3.4 (commit: 69630b9)
  • Data source type & version: Postgresql V11
  • OS Grafana is installed on: Kubernetes, with helm, but its the offical docker image grafana/grafana
  • User OS & Browser: Linux, Firefox 69.0.2
  • Grafana plugins:
  • Others:
@thall
Copy link
Author

thall commented Oct 11, 2019

I look into it quick this morning,

I found that if you wrap table_schema in https://github.com/grafana/grafana/blob/master/public/app/plugins/datasource/postgres/meta_query.ts#L78 with quote_ident() it returns all correct tables.

But if same table exists in multiple schemas you wouldn't see which belongs to which schema in the GUI. I think the proper way to fix this is to add another field in the GUI, before table-field that is a schema-field so you could choose the correct schema and then choose table. It could default to public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants