Changeset 4880
- Timestamp:
- 07/02/08 08:16:10 (6 months ago)
- Files:
-
- branches/1.0/turbogears/command/sacommand.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.0/turbogears/command/sacommand.py
r3617 r4880 3 3 from turbogears.util import get_model 4 4 try: 5 from sqlalchemy import MetaData, exceptions, Table, String 5 from sqlalchemy import MetaData, exceptions, Table 6 from sqlalchemy import String, Unicode, Text, UnicodeText 6 7 from turbogears.database import metadata, get_engine 7 8 except ImportError: … … 96 97 def compare_column(pyc, dbc): 97 98 rc = [] 99 pyt, dbt = pyc.type, dbc.type 100 101 # Table reflection cannot recognize Unicode, so check only for String 102 if isinstance(pyt, Unicode): 103 pyt = String(pyt.length) 104 elif isinstance(pyt, UnicodeText): 105 pyt = Text(pyt.length) 106 98 107 # Check type 99 if not isinstance(db c.type, pyc.type.__class__):100 rc.append('Change type to ' + py c.type.__class__.__name__)108 if not isinstance(dbt, pyt.__class__): 109 rc.append('Change type to ' + pyt.__class__.__name__) 101 110 102 111 # Check length (for strings) 103 112 else: 104 if isinstance(py c.type, String):105 if py c.type.length != dbc.type.length:106 rc.append('Change length to ' + str(py c.type.length))113 if isinstance(pyt, String): 114 if pyt.length != dbt.length: 115 rc.append('Change length to ' + str(pyt.length)) 107 116 108 117 # Check primary key … … 110 119 rc.append(pyc.primary_key and 'Make primary key' or 'Remove primary key') 111 120 112 # Check foreign keys 113 # TBD 121 # TODO: Check foreign keys 114 122 115 # Check default - disabled for now (didn't work on SQLite)116 #ifdbc.default != pyc.default:117 #rc.append('Change default to ' + str(pyc.default.arg))123 # Check default 124 if dbc.default is not None and dbc.default != pyc.default: 125 rc.append('Change default to ' + str(pyc.default.arg)) 118 126 119 # Check index - disabled for now (didn't work on SQLite)120 #ifdbc.index != pyc.index:121 #rc.append(pyc.index and 'Add index' or 'Remove index')127 # Check index 128 if dbc.index is not None and dbc.index != pyc.index: 129 rc.append(pyc.index and 'Add index' or 'Remove index') 122 130 123 131 return rc