Changeset 4377:812795b59437 in livinglogic.python.xist

Show
Ignore:
Timestamp:
03/03/11 16:21:35 (9 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Skip database objects named "BIN$*".

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • NEWS.rst

    r4373 r4377  
    99    :meth:`ll.orasql.Index.iternames` that skips those indexes that are generated 
    1010    by constraints. With this addition ``uls``/``ucp`` now list/copy constraints 
    11     and indexes properly. 
     11    and indexes properly. All ``iternames`` methods now skip objects whose name 
     12    starts with ``BIN$``. 
    1213 
    1314 
  • src/ll/orasql/__init__.py

    r4376 r4377  
    2929 
    3030 
    31 import datetime, itertools, cStringIO, errno, fnmatch 
     31import urllib, datetime, itertools, cStringIO, errno, fnmatch 
    3232 
    3333from cx_Oracle import * 
     
    814814 
    815815 
     816def makeurl(name): 
     817    return urllib.pathname2url(name).replace("/", "%2f") 
     818 
     819 
    816820class MixinNormalDates(object): 
    817821    """ 
     
    880884    def fixname(cls, name, code): 
    881885        code = code.split(None, 5) 
    882         code = u"create or replace {} {}\n{}".format(code[3], getfullname(name), code[5]) 
     886        code = u"create or replace {} {}\n{}".format(code[3], getfullname(name, None), code[5]) 
    883887        return code 
    884888 
     
    10851089        cursor = connection.cursor() 
    10861090        if schema=="all": 
    1087             cursor.execute("select decode(owner, user, null, owner) as owner, object_name from all_objects where lower(object_type) = :type order by owner, object_name", type=cls.type) 
    1088         else: 
    1089             cursor.execute("select null as owner, object_name from user_objects where lower(object_type) = :type order by object_name", type=cls.type) 
     1091            cursor.execute("select decode(owner, user, null, owner) as owner, object_name from all_objects where lower(object_type) = :type and object_name not like 'BIN$%' order by owner, object_name", type=cls.type) 
     1092        else: 
     1093            cursor.execute("select null as owner, object_name from user_objects where lower(object_type) = :type and object_name not like 'BIN$%' order by object_name", type=cls.type) 
    10901094        return ((row.object_name, row.owner) for row in cursor) 
    10911095 
     
    12571261            if i: 
    12581262                code.append(u",\n") 
    1259             code.append(u"\t{} {}".format(getfullname(rec.column_name), _columntype(rec))) 
     1263            code.append(u"\t{} {}".format(getfullname(rec.column_name, None), _columntype(rec))) 
    12601264            default = _columndefault(rec) 
    12611265            if default != "null": 
     
    13071311        cursor = connection.cursor() 
    13081312        if schema == "all": 
    1309             cursor.execute("select decode(owner, user, null, owner) as owner, table_name from all_tables order by owner, table_name") 
    1310         else: 
    1311             cursor.execute("select null as owner, table_name from user_tables order by table_name") 
     1313            cursor.execute("select decode(owner, user, null, owner) as owner, table_name from all_tables where table_name not like 'BIN$%' order by owner, table_name") 
     1314        else: 
     1315            cursor.execute("select null as owner, table_name from user_tables where table_name not like 'BIN$%' order by table_name") 
    13121316        return ((row.table_name, row.owner) for row in cursor) 
    13131317 
     
    14061410        cursor = connection.cursor() 
    14071411        if schema == "all": 
    1408             cursor.execute("select decode(owner, user, null, owner) as owner, constraint_name from all_constraints where constraint_type=:type order by owner, constraint_name", type=cls.constraint_type) 
    1409         else: 
    1410             cursor.execute("select null as owner, constraint_name from user_constraints where constraint_type=:type order by constraint_name", type=cls.constraint_type) 
     1412            cursor.execute("select decode(owner, user, null, owner) as owner, constraint_name from all_constraints where constraint_type=:type and constraint_name not like 'BIN$%' order by owner, constraint_name", type=cls.constraint_type) 
     1413        else: 
     1414            cursor.execute("select null as owner, constraint_name from user_constraints where constraint_type=:type and constraint_name not like 'BIN$%' order by constraint_name", type=cls.constraint_type) 
    14111415        return ((row.constraint_name, row.owner) for row in cursor) 
    14121416 
     
    16981702        cursor = connection.cursor() 
    16991703        if schema=="all": 
    1700             cursor.execute("select decode(owner, user, null, owner) as owner, object_name from (select owner, object_name from all_objects where object_type = 'INDEX' minus select owner, constraint_name as object_name from all_constraints where constraint_type in ('U', 'P')) order by owner, object_name") 
    1701         else: 
    1702             cursor.execute("select null as owner, object_name from (select object_name from user_objects where object_type = 'INDEX' minus select constraint_name as object_name from user_constraints where constraint_type in ('U', 'P')) order by object_name") 
     1704            cursor.execute("select decode(owner, user, null, owner) as owner, object_name from (select owner, object_name from all_objects where object_type = 'INDEX' minus select owner, constraint_name as object_name from all_constraints where constraint_type in ('U', 'P')) where object_name not like 'BIN$%' order by owner, object_name") 
     1705        else: 
     1706            cursor.execute("select null as owner, object_name from (select object_name from user_objects where object_type = 'INDEX' minus select constraint_name as object_name from user_constraints where constraint_type in ('U', 'P')) where object_name not like 'BIN$%' order by object_name") 
    17031707        return ((row.object_name, row.owner) for row in cursor) 
    17041708 
     
    26622666                names = (name[0] for name in Object.name2type[type].iternames(self.dbconnection, "user") if name[1] is None) 
    26632667                if len(path) == 1: 
    2664                     result = [url_.URL(u"{}/{}".format(type, name)) for name in names] 
     2668                    result = [url_.URL(u"{}/{}".format(type, makeurl(name))) for name in names] 
    26652669                else: 
    2666                     result = [url_.URL(name) for name in names] 
     2670                    result = [url_.URL(makeurl(name)) for name in names] 
    26672671        else: 
    26682672            raise IOError(errno.ENOTDIR, "Not a directory: {}".format(url)) 
     
    27042708        else: 
    27052709            name = url.path[1] 
    2706             code = Object.name2type[type](name.upper()).createddl(self.connection.dbconnection, term=False) 
     2710            code = Object.name2type[type](name).createddl(self.connection.dbconnection, term=False) 
    27072711            self.stream = cStringIO.StringIO(code.encode("utf-8")) 
    27082712