(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

On Fri, Sep 16, 2022 at 9:38 AM jens.t...@gmail.com <jens.troe...@gmail.com>
wrote:

> Hello,
>
> I’m noodling through the Composite Column Types
> <https://docs.sqlalchemy.org/en/14/orm/composites.html> examples, and
> can’t make it work. Based on the code on that page I put together a minimal,
> reproducible example
> <https://stackoverflow.com/help/minimal-reproducible-example> (attached)
> which fails with
>
>
>
>
>
> *Traceback (most recent call last):  File "/path/to/test.py", line 75, in
> <module>    assert v1.start > v2.startTypeError: '>' not supported between
> instances of 'Point' and 'Point'*
>
> Why is that? What am I missing? I expected to see SQL generated that
> implements the “greater than” between two *Point* instances (or perhaps
> *Vertex* instance, not sure, probably not).
>
> Much thanks!
> Jens
>
> --
> 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 sqlalchemy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sqlalchemy/149c1ae1-94af-4a4e-884c-171f72eb010bn%40googlegroups.com
> <https://groups.google.com/d/msgid/sqlalchemy/149c1ae1-94af-4a4e-884c-171f72eb010bn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CAFHwexeqBnAUrWJbrOyKS3aL5FsZvnCGOoU-VuOGeSOHh41aEQ%40mail.gmail.com.

Reply via email to