Hi All,
For the following model:
class Header(Base):
__tablename__ = 'header'
id = Column(Integer, primary_key=True)
message_id = Column(Integer,ForeignKey('message.id'))
name = Column(String(50))
value = Column(Text(255))
sqlalchemy-migrate's SchemaDiff tool against the table freshly created
in MySQL gives:
Schema diffs:
tables with differences: header
header with different declaration of columns in database:
[(Column('value', Text(length=255, convert_unicode=False,
assert_unicode=None, unicode_error=None, _warn_on_bytestring=False),
table=<header>), Column(u'value', TINYTEXT(), table=<header>), 'value
TEXT(255)', 'value TINYTEXT')]
The schema diff stuff basically does the following to get the database
column declaration with SA 0.6+:
from sqlalchemy.ext import compiler
from sqlalchemy.schema import DDLElement
class DefineColumn(DDLElement):
def __init__(self, col):
self.col = col
@compiler.compiles(DefineColumn)
def compile(elem, compiler, **kw):
return compiler.get_column_specification(elem.col)
def get_column_specification(col):
return str(DefineColumn(col).compile(dialect=self.conn.dialect))
How can it be changed so that the column reflected from the DB and the
column calculated from the model end up being the same?
cheers,
Chris
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.