Changeset 726 for branches/4.x


Ignore:
Timestamp:
Jan 12, 2016, 11:33:00 AM (4 years ago)
Author:
cito
Message:

Use query parameter again

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.x/pg.py

    r725 r726  
    424424            if schemas:  # non-empty path
    425425                # search schema for this object in the current search path
     426                # (we could also use unnest with ordinality here to spare
     427                # one query, but this is only possible since PostgreSQL 9.4)
    426428                q = ' UNION '.join(
    427429                    ["SELECT %d::integer AS n, '%s'::name AS nspname"
    428430                        % s for s in enumerate(schemas)])
    429                 q = ("SELECT nspname FROM pg_class"
    430                     " JOIN pg_namespace"
    431                     " ON pg_class.relnamespace = pg_namespace.oid"
     431                q = ("SELECT nspname FROM pg_class r"
     432                    " JOIN pg_namespace s ON r.relnamespace = s.oid"
    432433                    " JOIN (%s) AS p USING (nspname)"
    433                     " WHERE pg_class.relname = '%s'"
    434                     " ORDER BY n LIMIT 1" % (q, cl))
    435                 schema = self.db.query(q).getresult()
     434                    " WHERE r.relname = $1 ORDER BY n LIMIT 1" % q)
     435                schema = self.db.query(q, (cl,)).getresult()
    436436                if schema:  # schema found
    437437                    schema = schema[0][0]
Note: See TracChangeset for help on using the changeset viewer.