Changeset 428
- Timestamp:
- 04/06/07 08:24:59
- Files:
-
- trunk/storage/db.py (modified) (8 diffs)
- trunk/storage/storeado.py (modified) (4 diffs)
- trunk/test/zoo_fixture.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/storage/db.py
r427 r428 53 53 self.reserve_lock = threading.Lock() 54 54 55 # AdapterOverrides55 # Config Overrides 56 56 def get_option(name): 57 57 item = allOptions.get(name) … … 60 60 return item 61 61 62 adapter= get_option('Database Class')63 if adapter:64 self.databaseclass = adapter62 dbclass = get_option('Database Class') 63 if dbclass: 64 self.databaseclass = dbclass 65 65 66 66 allOptions = dict([(str(k), v) for k, v in allOptions.iteritems()]) … … 407 407 % (oldname, t.name)) 408 408 oldcol = c[0] 409 pytype1 = self.db.typeadapter.python_type(oldcol.dbtype)410 # Note we use newname, which assumes that property is in the class.411 pytype2 = getattr(cls, newname).type412 oldcol.imperfect_type = not self.db.typeadapter.related(pytype1, pytype2)413 409 # Use the superclass call to avoid DROP COLUMN/ADD COLUMN. 414 410 dict.__setitem__(t, oldname, oldcol) … … 528 524 dbcols = dict([(c.name, c) for c in table.itervalues()]) 529 525 indices = cls.indices() 530 related = self.db.typeadapter.related531 526 for pkey in cls.properties: 532 527 colname = self.schema._column_name(table.name, pkey) … … 572 567 continue 573 568 574 # Set imperfect_type 575 newtype = getattr(cls, pkey).type 576 if newtype != col.pytype: 577 col.imperfect_type = not related(newtype, col.pytype) 578 col.pytype = newtype 569 col.pytype = getattr(cls, pkey).type 579 570 580 571 # Try to find matching Index objects. Because index names are … … 674 665 675 666 for cname, c in table.iteritems(): 676 ptype = self.schema.db.typeadapter.python_type(c.dbtype)677 if ptype == int and c. hints.get('bytes') in (1, '1'):667 ptype = c.pytype 668 if ptype == int and c.dbtype.bytes == 1: 678 669 # This is probably a bool 679 670 ptype = bool 680 del c.hints['bytes']681 671 p = AutoUnitClass.set_property(cname, ptype) 682 672 if c.autoincrement: 683 673 AutoUnitClass.sequencer = dejavu.UnitSequencerInteger(int, c.initial) 684 674 p.default = c.default 685 p.hints = c.hints.copy() 675 p.hints = dict([(k, getattr(c.dbtype, k)) 676 for k in ("bytes", "precision", "scale") 677 if hasattr(c.dbtype, k)]) 686 678 p.index = (cname in table.indices) 687 679 … … 731 723 sequencer = None 732 724 for cname, c in table.iteritems(): 733 ptype = self.schema.db.typeadapter.python_type(c.dbtype)734 if ptype == int and c. hints.get('bytes') in (0, '0', 1, '1'):725 ptype = c.pytype 726 if ptype == int and c.dbtype.bytes == 1: 735 727 # This is probably a bool 736 728 ptype = bool 737 del c.hints['bytes']738 729 739 730 mod = ptype.__module__ … … 757 748 index = ", index=True" 758 749 759 hints = "" 760 if c.hints: 761 hints = ", hints=%r" % c.hints 750 hints = dict([(k, getattr(c.dbtype, k)) 751 for k in ("bytes", "precision", "scale") 752 if hasattr(c.dbtype, k)]) 753 if hints: 754 hints = ", hints=%r" % hints 755 else: 756 hints = "" 762 757 763 758 prop = (" %s = UnitProperty(%s%s%s%s)" trunk/storage/storeado.py
r427 r428 1 1 import warnings 2 2 3 from geniusql.providers import ado 3 from geniusql.providers import ado, sqlserver, msaccess 4 4 from dejavu import errors 5 5 from dejavu.storage import db 6 6 7 7 8 class StorageManagerADO (db.StorageManagerDB):8 class StorageManagerADO_SQLServer(db.StorageManagerDB): 9 9 """StoreManager to save and retrieve Units via ADO 2.7. 10 10 … … 12 12 """ 13 13 14 databaseclass = ado.ADODatabase 15 16 17 class StorageManagerADO_SQLServer(StorageManagerADO): 18 19 databaseclass = ado.SQLServerDatabase 14 databaseclass = sqlserver.SQLServerDatabase 20 15 21 16 def __init__(self, arena, allOptions={}): … … 25 20 26 21 27 class StorageManagerADO_MSAccess(StorageManagerADO): 22 class StorageManagerADO_MSAccess(db.StorageManagerDB): 23 """StoreManager to save and retrieve Units via ADO 2.7. 24 25 You must run makepy on ADO 2.7 before installing. 26 """ 28 27 # Jet Connections and Recordsets are always free-threaded. 29 28 30 databaseclass = ado.MSAccessDatabase29 databaseclass = msaccess.MSAccessDatabase 31 30 32 31 def __init__(self, arena, allOptions={}): … … 38 37 39 38 def _make_column(self, cls, key): 40 col = StorageManagerADO._make_column(self, cls, key)39 col = db.StorageManagerDB._make_column(self, cls, key) 41 40 if col.dbtype == "MEMO": 42 41 for assoc in cls._associations.itervalues(): trunk/test/zoo_fixture.py
r427 r428 989 989 if db: 990 990 import math 991 maxprec = db. typeadapter.numeric_max_precision991 maxprec = db.adapterset.numeric_max_precision() 992 992 if maxprec == 0: 993 993 # SQLite, for example, must always use TEXT. … … 1160 1160 v2 = copy.hints.get(k) 1161 1161 if v2 != 0 and v2 < v: 1162 self.fail("%s.%s hint [%s]%s not >= %s" %1162 self.fail("%s.%s hints[%s]: %s not >= %s" % 1163 1163 (cls.__name__, pname, k, v2, v)) 1164 1164 else:
