On Thu, Jun 9, 2011 at 7:21 PM, Michael Bayer <mike...@zzzcomputing.com> wrote: > > On Jun 9, 2011, at 12:37 PM, Eric Lemoine wrote: > >> On Thu, Jun 9, 2011 at 6:28 PM, Michael Bayer <mike...@zzzcomputing.com> >> wrote: >>> >>> >>> That's the default adaption provided by TypeEngine.adapt(). Provide your >>> own adapt() that does what's needed. For examples see Interval, Enum. >> >> Ok, I'll take a look at adapt(). Note that our Geometry type isn't >> specific to Oracle though. > > When you get it going, if you can show us what you're doing, we can create a > prototypical version of your type, demonstrating the kind of "add new > arguments per dialect" functionality it has, and add it to our test suite, > to ensure those usage patterns don't break. SQLAlchemy usually uses > distinct type classes per backend to handle backend-specific arguments, so > your approach of allowing DB-specific keyword arguments to a single type, > which while entirely appropriate in your case, isn't a pattern we test for at > the moment.
See the attached patch. Please tell if I should create a Trac ticket and attach my patch to it. Cheers, -- Eric Lemoine Camptocamp France SAS Savoie Technolac, BP 352 73377 Le Bourget du Lac, Cedex Tel : 00 33 4 79 44 44 96 Mail : eric.lemo...@camptocamp.com http://www.camptocamp.com -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
diff --git a/test/sql/test_types.py b/test/sql/test_types.py --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -273,6 +273,18 @@ Float().dialect_impl(pg).__class__ ) + def test_user_defined_dialect_specific_args(self): + class MyType(types.UserDefinedType): + def __init__(self, foo='foo', **kwargs): + self.foo = foo + self.dialect_specific_args = kwargs + def adapt(self, cls): + return cls(foo=self.foo, **self.dialect_specific_args) + t = MyType(bar='bar') + a = t.dialect_impl(testing.db.dialect) + eq_(a.foo, 'foo') + eq_(a.dialect_specific_args['bar'], 'bar') + @testing.provide_metadata def test_type_coerce(self): """test ad-hoc usage of custom types with type_coerce()."""