FWIW I put a rough patch together awhile ago (I can't find it or the discussion unfortunately) that attempted to make Transforms usable as expressions. They share partial APIs but not the full set which made that first attempt quite messy/hacky. I'm not aware of any reasons that they couldn't be combined in some way.
Cheers On Wednesday, 25 March 2015 20:54:39 UTC+11, Alex Hill wrote: > > Hi list, > > The thread about reimplementing the date-based lookups[1] reminded me of > something that was bugging me a couple of days ago. > > There's some overlap between Funcs (of arity 1) and Transforms. They seem > to fundamentally do the same thing – wrap an expression in some arbitrary > SQL – but with a different interface. > > It seems wrong that some functionality can be tied up in a Transform and > not available as a Func, and vice-versa. For instance, the built-in Length > function isn't available as a transform, and the built-in contrib.postgres > Unaccent transform isn't available as a function. > > It would be good to be able to easily register functions of arity 1 as > transforms, using a decorator for example, to make them available in both > contexts. > > Can all possible transforms be defined like this? That is, are transforms > strictly a special case of functions or can they do more? > > Cheers, > Alex > > [1] https://groups.google.com/forum/#!topic/django-developers/WYWrQkBJ2hs > > > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/6dacb872-a581-4e18-8ad0-f12496ed661c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.