OK first problem is, the SQL you showed me is:

select (
    select (array_agg(unwave.restw)) as restwarr
    from (
        select (
            unnest(w.wavelength)/(1+n.z)) as restw
            from mangadatadb.wavelength as w
        ) as unwave
    )
from mangadatadb.cube as c
join mangasampledb.manga_target as m on m.pk=c.manga_target_pk
join mangasampledb.manga_target_to_nsa as t on t.manga_target_pk=m.pk
join mangasampledb.nsa as n on n.pk=t.nsa_pk
join mangadatadb.wavelength as w on w.pk=c.wavelength_pk limit 5;


that has three SELECTs, a LIMIT, and no WHERE.

Then the code has three calls to session.query() inside "def restwave", no LIMIT. Then theres *another* call to session.query(Cube.restwave) with a filter() (e.g. a WHERE), and no LIMIT.

These don't match up. Can you show me the *complete* SQL you want at the very end of the whole thing? I don't know how many levels of SELECT you want (the code asks for four), and I don't know if you want the LIMIT inside the subquery, and other things like that. That is, where does "def restwave()" end and the outer query takes over.







On 08/03/2016 11:57 AM, Brian Cherinka wrote:
Ok. Here is my test file.  I tried to set it up as much as I could, but
I don't normally set up my db and sessions this way, so you may have to
hack a bit here and there to finish some setup.  My original setup has
classes from two different schema.  I don't know if that makes any
difference.  I've also added some lines to add objects into the tables
that I think you can use to recreate my problem.   Let me know if you
need anything more in this file.

--
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
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
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 post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to