[sqlalchemy] Re: SchemaGenerator.get_column_default_string
On Dec 21, 2007, at 2:10 PM, Christophe de VIENNE wrote: > > 2007/12/21, Michael Bayer <[EMAIL PROTECTED]>: >>> In the HEAD version, the table creation does not set the default >>> values on the columns (tested on mysql and mssql) >>> It seems that the function SchemaGenerator.get_column_default_string >>> (in compiler.py) always returns None, even if a default value is >>> specified. >>> >>> 801 def get_column_default_string(self, column): >>> 802 if isinstance(column.default, schema.PassiveDefault): >>> 803 if isinstance(column.default.arg, basestring): >>> 804 return "'%s'" % column.default.arg >>> 805 else: >>> 806 return unicode(self._compile(column.default.arg, >>> None)) >>> 807 else: >>> 808 return None >>> >> >> ColumnDefaults are "in-python" default generators, they dont get >> rendered into DDL. PassiveDefault is used to produce a DDL-rendered >> default: >> >> http://www.sqlalchemy.org/docs/04/metadata.html#metadata_defaults_passive >> > > What is really disturbing is that Column(..., PassiveDefault(u'N')) > and Column(..., default=PassiveDefault(u'N')) don't have the same > behavior. default= should really be fixed to do something meaningful, I know. we'll fix that. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: SchemaGenerator.get_column_default_string
2007/12/21, Michael Bayer <[EMAIL PROTECTED]>: > > In the HEAD version, the table creation does not set the default > > values on the columns (tested on mysql and mssql) > > It seems that the function SchemaGenerator.get_column_default_string > > (in compiler.py) always returns None, even if a default value is > > specified. > > > > 801 def get_column_default_string(self, column): > > 802 if isinstance(column.default, schema.PassiveDefault): > > 803 if isinstance(column.default.arg, basestring): > > 804 return "'%s'" % column.default.arg > > 805 else: > > 806 return unicode(self._compile(column.default.arg, > > None)) > > 807 else: > > 808 return None > > > > ColumnDefaults are "in-python" default generators, they dont get > rendered into DDL. PassiveDefault is used to produce a DDL-rendered > default: > > http://www.sqlalchemy.org/docs/04/metadata.html#metadata_defaults_passive > What is really disturbing is that Column(..., PassiveDefault(u'N')) and Column(..., default=PassiveDefault(u'N')) don't have the same behavior. Anyway, now I understand what was my mistake. Thank you ! Christophe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: SchemaGenerator.get_column_default_string
On Dec 21, 2007, at 11:57 AM, Christophe de VIENNE wrote: > > Hi all, > > In the HEAD version, the table creation does not set the default > values on the columns (tested on mysql and mssql) > It seems that the function SchemaGenerator.get_column_default_string > (in compiler.py) always returns None, even if a default value is > specified. > > 801 def get_column_default_string(self, column): > 802 if isinstance(column.default, schema.PassiveDefault): > 803 if isinstance(column.default.arg, basestring): > 804 return "'%s'" % column.default.arg > 805 else: > 806 return unicode(self._compile(column.default.arg, > None)) > 807 else: > 808 return None > ColumnDefaults are "in-python" default generators, they dont get rendered into DDL. PassiveDefault is used to produce a DDL-rendered default: http://www.sqlalchemy.org/docs/04/metadata.html#metadata_defaults_passive --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---