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