inappropriate lower() call against table name in PG dialect

Issue #2256 resolved
Former user created an issue

Just caught this little bugger:

def has_table(self, connection, table_name, schema=None):
    # seems like case gets folded in pg_class...
    if schema is None:
        cursor = connection.execute(
            sql.text(
            "select relname from pg_class c join pg_namespace n on "
            "n.oid=c.relnamespace where n.nspname=current_schema() and "
            "lower(relname)=:name",
            bindparams=[                       sql.bindparam('name', unicode(**table_name.lower()**),
                    type_=sqltypes.Unicode)](

) ) )

This results in a failure when trying to work with a table named FOO when a table named foo is already in the database. Postgres at least allows both versions to coexist.

Comments (4)

  1. Mike Bayer repo owner
    • assigned issue to
    • changed milestone to 0.7.3
    • changed component to postgres

    its not immediately clear if that's going to break things for folks who are relying upon it. Have you run the full test suite against PG to ensure everything continues passing ?

  2. Log in to comment