Chris Withers wrote:
> Michael Bayer wrote:
>>> Please let me know if there's a better way!
>>
>> you should use TypeDecorator.load_dialect_impl(dialect), check the
>> "name" of the dialect,
>
> Why the name rather than doing:
>
> if isinstance(dialect,MySQLDialect):
you could do that too, though the "name" is more solid
>
>> then return either MSString(arguments) or super.load_dialect_impl().
>
> Okay, but where do I get the arguments from?
you have to stick them on your custom type. i.e. your typedecorator
object.
>
> super(CaseSensitiveUnicode,self).load_dialect_impl(dialect) leads to:
>
> 263 if isinstance(self.impl, TypeDecorator):
> 264 return self.impl.dialect_impl(dialect)
> 265 else:
> 266 return dialect.type_descriptor(self.impl)
>
> ...which then ends up in some adapt_type stuff that looked pretty hairy.
> All I want to do is insert a collation argument when the dialect is
> MySQL...
this is the code:
def load_dialect_impl(self, dialect):
if dialect.name == 'mysql':
return MSString(self.length, collation=self.collation_whatever)
else:
return super(MyType, self).load_dialect_impl(dialect)
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
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.