Hello, all.

   I am trying to reshape the (somewhat tricky) SQL query below into 
something SQLAlchemy can generate, and I just hit a wall:

This is the query: 
SELECT (c).csr_id, (c).not_before, (c).not_after FROM (SELECT (SELECT c 
FROM certificate c WHERE c.csr_id=csr.id ORDER BY c.not_after DESC LIMIT 1) 
AS c FROM csr offset 0) s;

And, I just can't seem to get SQLAlchemy to emit a correlated scalar 
subquery like this.  There ought to be something, but for the life of me I 
can't seem to make it happen.

InklessPen tried to help me on IRC, and we got something, but it's still 
not quite the same,
 https://gist.github.com/inklesspen/49e69e1f33f3852d348a 

A reduced model is below, 


class CSR(Base):
    certificates = _orm.relationship("Certificate", backref="csr")

class Certificate(Base):
    not_before = _sa.Column(_sa.DateTime, nullable=False)
    not_after = _sa.Column(_sa.DateTime, nullable=False)
    csr_id = _fkcolumn(CSR.id, nullable=False)


Regards,
  D.S.

-- 
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to