Mercurial > sqlpython
changeset 508:6f6e43ed656c
only one case converter per db adapter
author | catherine.devlin@gmail.com |
---|---|
date | Thu, 23 Sep 2010 09:42:28 -0400 |
parents | fcaf28842db7 |
children | 85495d4d6c73 |
files | sqlpython/connections.py sqlpython/sqlpyPlus.py |
diffstat | 2 files changed, 22 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/sqlpython/connections.py Wed Sep 22 23:48:20 2010 -0400 +++ b/sqlpython/connections.py Thu Sep 23 09:42:28 2010 -0400 @@ -195,7 +195,7 @@ return '=' def objects(self, target, opts): match = self.identifier_regex.search(target) - object_type = self.object_type_case(match.group('object_type') or '%') + object_type = self.name_case(match.group('object_type') or '%') names = [n.strip() or '%' for n in self.name_case(match.group('remainder').replace('*', '%').replace('?', '_')).split('.')] + ['%', '%'] replacements = {'name1_comparitor': self.comparitor(names[0]), 'name2_comparitor': self.comparitor(names[1]), @@ -294,8 +294,6 @@ default_port = 5432 def name_case(self, s): return s.lower() - def object_type_case(self, s): - return s.upper() def set_defaults(self): self.port = os.getenv('PGPORT') or self.default_port self.database = os.getenv('ORACLE_SID') @@ -324,13 +322,15 @@ NULL AS synonym_name FROM pg_namespace ns JOIN pg_class c ON (ns.oid = c.relnamespace) - WHERE ( ns.nspname = %%(schema)s - OR position(ns.nspname in (SELECT setting FROM pg_settings WHERE name = 'search_path')) > 0 - OR ( %(all)s - AND ns.nspname = 'pg_catalog' - ) + WHERE ( ( ns.nspname = %%(schema)s + OR position(ns.nspname in (SELECT setting FROM pg_settings WHERE name = 'search_path')) > 0 + OR %(all)s + ) + AND c.relname %(name1_comparitor)s %%(name1)s ) - AND c.relname %(name1_comparitor)s %%(name1)s + OR ( ns.nspname %(name1_comparitor)s %%(name1)s + AND c.relname %(name2_comparitor)s %%(name2)s + ) ) subq WHERE object_type %(object_type_comparitor)s %%(object_type)s ORDER BY object_type, schema, object_name %(sort)s""" @@ -345,8 +345,9 @@ WHERE owner %s %s AND UPPER(text) LIKE %s""" gerald_types = {'table': gerald.postgres_schema.Table, - 'view': gerald.postgres_schema.View} - + 'view': gerald.postgres_schema.View, + 'trigger': gerald.postgres_schema.Trigger} + class OracleInstance(DatabaseInstance): rdbms = 'oracle' default_port = 1521 @@ -354,7 +355,6 @@ re.IGNORECASE) def name_case(self, s): return s.upper() - object_type_case = name_case def uri(self): if self.hostname: uri = '%s://%s:%s@%s:%s/%s' % (self.rdbms, self.username, self.password, @@ -432,7 +432,14 @@ 'Puts a tuple of (name, value) pairs into the bind format desired by cx_Oracle' return dict((b[0], b[1].upper()) for b in binds) gerald_types = {'TABLE': gerald.oracle_schema.Table, - 'VIEW': gerald.oracle_schema.View} + 'VIEW': gerald.oracle_schema.View, + 'TRIGGER': gerald.oracle_schema.Trigger, + 'SEQUENCE': gerald.oracle_schema.Sequence, + 'PACKAGE': gerald.oracle_schema.Package, + 'DATABASE LINK': gerald.oracle_schema.DatabaseLink, + 'FUNCTION': gerald.oracle_schema.CodeObject, + 'PROCEDURE': gerald.oracle_schema.CodeObject + } if __name__ == '__main__':
--- a/sqlpython/sqlpyPlus.py Wed Sep 22 23:48:20 2010 -0400 +++ b/sqlpython/sqlpyPlus.py Thu Sep 23 09:42:28 2010 -0400 @@ -884,7 +884,8 @@ txt = centeredSlice(txt, center=opts.num+1, width=opts.width) txt = '\n'.join(txt) else: - txt = 'REMARK BEGIN %s/%s/%s\n%s\nREMARK END\n' % (owner, object_type, name, txt) + txt = 'REMARK BEGIN %(object_label)s\n%(txt)s\nREMARK END %(object_label)s\n' % { + 'object_label': self.object_label(object_type, owner, name, None), 'txt': txt} self.poutput(txt) if opts.dump: self.stdout.close()