Re: [sqlalchemy] sorting hybrid_properties getting NotImplementedError: Operator 'getitem' is not supported on this expression

2021-11-19 Thread gvv
Hi Mike, Thank you very much. A thousand years and I still wouldn't be able to figure that one out. And thank you also for clarifying use of Comparators - makes coding simpler with expression instead. Thanks, George On Saturday, 20 November 2021 at 00:28:00 UTC+11 Mike Bayer wrote: >

Re: [sqlalchemy] raise error on insert/update PK?

2021-11-19 Thread Simon King
You ought to be able to use the "sqlalchemy.func" system: https://docs.sqlalchemy.org/en/14/core/tutorial.html#functions server_default=sa.func.gen_random_uuid() Hope that helps, Simon On Fri, Nov 19, 2021 at 6:21 AM jens.t...@gmail.com wrote: > > Tim, > > I wanted to offload the UUID

Re: [sqlalchemy] sorting hybrid_properties getting NotImplementedError: Operator 'getitem' is not supported on this expression

2021-11-19 Thread Mike Bayer
there's no need to use custom Comparator objects, these are difficult to get right and there's not really any need to use them except in the extremely unusual case that you need specific SQL operators to do something different, which itself is not really a thing in modern SQLAlchemy. Just use

Re: [sqlalchemy] sorting hybrid_properties getting NotImplementedError: Operator 'getitem' is not supported on this expression

2021-11-19 Thread Mike Bayer
heya - haven't run it yet but if you are on SQLAlchemy 1.3, the signature for case() is different (sorry, note the list ): https://docs.sqlalchemy.org/en/13/core/sqlelement.html?highlight=case#sqlalchemy.sql.expression.case expr = case( [(cls.Type == "SELL", cast(cls.Units *