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] 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 *

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

2021-11-18 Thread gvv
Hi All, Sorry About my previous post - did not read the posting Guidelines. Using Sqlalchemy 1.3.23 In this example using SQLlite memory, but is also happening in Postgresql 12.9 class TotalCostComparator(Comparator): def __init__(self, cls): expr = case( (cls.Type ==

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

2021-11-18 Thread gvv
Hi All, Using Sqlalchemy 1.3.23 I am getting a NotImplementedError: Operator 'getitem' is not supported on this expression when sorting on some hybrid_properties. I have attached a sample code to replicate it. falls over with the following traceback: Traceback (most recent call last): File