【问题标题】:How to join on spatial functions in Peewee?如何在 Peewee 中加入空间功能?
【发布时间】:2019-08-17 05:39:10
【问题描述】:

我正在努力弄清楚如何根据相当常见的表格 postgis 模式在 Peewee 中加入表格。我需要加入一个基于 postgis 函数(st_contains)的表。我想它看起来像:

Station.select().join(Location, on=fn.ST_Intersects(Station.geom, Location.geom)).where(Location.name == 'Ravenswood')

如果支持,上述查询将返回名为 Ravenswood 的位置中的所有站点。等效的 SQL 将是:

SELECT station.name, station.district, station.line
FROM station INNER JOIN location ON ST_Intersects(station.geom, loc.geom)
WHERE location.name = 'Ravenswood';

不幸的是,我的实验似乎都以这个简短的回溯结束:

File "/Users/j.../python2.7/site-packages/peewee.py", line 1555, in generate_joins
left_field = field.to_field
AttributeError: 'NoneType' object has no attribute 'to_field'

peewee 支持这个吗?我在文档中找不到它。

【问题讨论】:

  • Peewee 的连接生成检查表达式但不检查函数调用。我已在 61034c569e9679832327332aee0348a57a2b990c 中修复了此错误。如果您使用 peewee master,您现在应该可以运行查询了。

标签: postgis peewee


【解决方案1】:

Peewee 的连接生成检查表达式但不检查函数调用。我已经在61034c5(在 v2.6.1 中发布)中修复了这个错误。如果您使用 peewee master,您现在应该可以运行查询了。

【讨论】:

    猜你喜欢
    • 2018-04-25
    • 1970-01-01
    • 2011-01-16
    • 2016-10-26
    • 1970-01-01
    • 1970-01-01
    • 2016-10-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多