This is my error.
I'm creating a custom Column object (via subclassing), because I want
to override operator behaviour for .in_
to provide geometry support to a column. I must of missed something
in implementing the column subclass.
Currently, I'm just returning a string from the in_( method of my
sublass, using self.name as the name of the column in which to
perform the clause:
def in_(self, bounding_box):
"""Override the ``in`` operator to do a spatial query.
>>> model.Entity.c.geo_column.in_(.... ) # BOX3D(%f, %f, %f,
%f)::box3d
"""
binary_expr = self.name
binary_expr += " && SetSRID('BOX3D(%f %f, %f %f)'::box3d"
binary_expr %= bounding_box.totuple()
binary_expr += ", %d)" % srid(bounding_box.srs)
return binary_expr
Which produces a PostGIS binary query expression such as:
WHERE point && SetSRID('BOX3D(-74.847708 39.884318, -74.823589
39.904667)'::box3d, 4326)
When doing a cross-table join, i need to label the column, so that I
can fetch related entities by location:
q = model.GeoRoute.query().add_entity(model.GeoLocation)
q = q.filter(model.GeoLocation.c.point.label("center").in_(bb))
q.all() # this works
q.count() # this doesn't, because the table containing the column
'point' isn't included in the from list.
Sorry for the red-herring.
Matt
On Aug 9, 12:29 pm, mattrussell <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have query which works which joins two tables together (Am using
> elixir and tesla trunks, SA 0.3.10):
>
> q = model.Thing.query()
> q = q.add_entity(model.OtherThing)
> q = q.filter(my_filter_expr)
> q.all()
>
> This executes fine.
>
> but doing: q.count() (Am trying to use webhelpers.paginate) ,
>
> <class 'sqlalchemy.exceptions.SQLError'>: (ProgrammingError) column
> "x" does not exist
> Using the engine.echo = True, I can see that this is because the
> SELECT statement doesn't include the table included by the
> 'add_entity' clause in the select statemnt for count(). Is there a way
> to force it to? or i am barking up the wrong tree?
>
> :)
>
> Matt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---