Thank you Simon!

That worked indeed and makes a lot of sense. I think I misinterpreted the 
documentation a bit in that sense; it did puzzle that SQLA would patch all 
these mapped objects…

Based on your example:

*>>> dbsession.query(Vertex).filter(Vertex.start > Point(2, 2)).all()*
*[<__main__.Vertex object at 0x1065f5690>]*

Cheers,
Jens


On Friday, September 16, 2022 at 7:20:40 PM UTC+10 Simon King wrote:

> (I haven't used any of these features, so the following is just a guess)
>
> In your assertion, you are comparing two *Point instances*. The SQLAlchemy 
> comparator_factory mechanism has not made any changes to the Point class 
> itself, and Point doesn't define __gt__, hence your TypeError.
>
> The point of the comparator_factory is to add class-level behaviour when 
> you are building SQL expressions. In this case, you could write a query 
> like this:
>
>     query = dbsession.query(Vertex).filter(Vertex.start > Point(2, 2))
>
> Hope that helps,
>
> Simon
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/0d2ee17a-9132-43f7-99c7-6ec9803600bdn%40googlegroups.com.

Reply via email to