pgbedrock icon indicating copy to clipboard operation
pgbedrock copied to clipboard

Support schema names with dashes

Open zcmarine opened this issue 6 years ago • 1 comments

Summary Postgres doesn't like dashes in identifiers. To solve this, we can double-quote identifiers. We currently do this for tables and rolenames, but we don't do it for schemas. As a result, a spec like the below will cause an error:

zmarine:
    can_login: true
    owns:
        schemas:
            - schema-with-dash
    privileges:
        tables:
            read:
                - schema-with-dash.*

Postgres will complain that there is a syntax error at or near "-". To resolve this, we should double-quote all schemas as well.

Key Actions

  • Identify all places where schemas are used and ensure they are double-quoted. This will likely just be modifying the queries within context.py to make sure they all double-quote schemas, but there may be downstream places that do comparisons / lookups of a schema and don't double-quote it.
  • In addition, the submodules that use schemas (ownerships.py and privileges.py) will need to quote schemas that they are working with to make sure lookups with context.py work properly.
  • This is true for all other issues as well, but we definitely want a test here to verify that this behavior works as expected.

zcmarine avatar Mar 27 '18 16:03 zcmarine

Ah. Totally missed this in my cursory glance over the issue tracker. Erghm.

Gastove avatar Jul 20 '18 18:07 Gastove