the "array()" construct currently represents only an array literal
of column expressions, and it produces the PG expression ARRAY[],
which is not what you want here. For a vanilla array() function,
use func.array():
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
data = Column(Integer)
e = create_engine("postgresql://scott:tiger@localhost/test",
echo=True)
Base.metadata.drop_all(e)
Base.metadata.create_all(e)
s = Session(e)
s.add_all([A(data=1), A(data=2), A(data=3)])
s.commit()
subq = s.query(A.data).subquery().as_scalar()
q = s.query(A, func.array(subq))
print q.all()
output:
SELECT
a.id AS a_id, a.data AS a_data, array((SELECT a.data
FROM a)) AS array_1
FROM a
--
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+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.