Changeset 284 for trunk/module/pg.py


Ignore:
Timestamp:
Apr 14, 2006, 12:13:22 PM (14 years ago)
Author:
darcy
Message:

If caller supplies key dictionary, make sure that all has a namespace.
Create unit test for change.
Document change in changelog.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/module/pg.py

    r283 r284  
    66# Improved by Christoph Zwerschke
    77#
    8 # $Id: pg.py,v 1.44 2006-04-13 17:56:04 darcy Exp $
     8# $Id: pg.py,v 1.45 2006-04-14 16:13:22 darcy Exp $
    99#
    1010
     
    216216
    217217                """
    218                 # Get all the primary keys at once
     218                # First see if the caller is supplying a dictionary
    219219                if isinstance(newpkey, DictType):
    220                         self.__pkeys = newpkey
    221                         return newpkey
     220                        # make sure that we have a namespace
     221                        self.__pkeys = {}
     222                        for x in newpkey.keys():
     223                                if x.find('.') == -1:
     224                                        self.__pkeys['public.' + x] = newpkey[x]
     225                                else:
     226                                        self.__pkeys[x] = newpkey[x]
     227
     228                        return self.__pkeys
     229
    222230                qcl = _join_parts(self._split_schema(cl)) # build qualified name
    223231                if newpkey:
    224232                        self.__pkeys[qcl] = newpkey
    225233                        return newpkey
     234
     235                # Get all the primary keys at once
    226236                if self.__pkeys == {} or not self.__pkeys.has_key(qcl):
    227                         # if not found, determine pkey again in case it was added after we started
     237                        # if not found, check again in case it was added after we started
    228238                        for r in self.db.query("SELECT pg_namespace.nspname"
    229239                                ",pg_class.relname,pg_attribute.attname FROM pg_class"
Note: See TracChangeset for help on using the changeset viewer.