Skip to content

has_table does not work for table names that need escaping #25

@rad-pat

Description

@rad-pat

has_table method does not works for tables/schemas with characters that need escaping e.g. test-schema, test-table

Current code uses EXISTS TABLE schema.name, this doesn't appear to work if table name needs escaping.

Suggest use of information_schema like e.g. get_columns

def has_table(self, connection, table_name, schema=None, **kw):
    full_table = table_name
    query = """
        select 1
        from information_schema.columns
        where table_name = '{table_name}'
    """.format(
        table_name=table_name
    )

    query = "{query} and table_schema = '{schema}'".format(
        query=query, schema=schema
    )
    result = connection.execute(text(query))
    return bool(result.first())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions