Jaymon / prom

A PostgreSQL or SQLite orm for Python
MIT License
22 stars 4 forks source link

Subquery failure #132

Closed Jaymon closed 2 years ago

Jaymon commented 3 years ago
        sq = SubFoo.query.select_pk().eq_che(che_id).desc__created()
        sq.limit(limit).page(page)
        values = Content.query.in_pk(sq).get()

Failed with:

[E] operator does not exist: character = bigint
[27497]: LINE 6:   "_id" IN (SELECT
[27497]:                 ^
[27497]: HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.

I'm not sure why this is failing

Jaymon commented 3 years ago

Wait, I do know why it's failing, because I was selecting the primary key of SubFoo when what I wanted was the content_id that matched up with Content, so the fix was:

sq = SubFoo.query.select_content_id().eq_che(che_id).desc__created()
sq.limit(limit).page(page)
values = Content.query.in_pk(sq).get()

I still think this might be a bug or there should be a way to cast here, so I should look into it when I've got some time