Python: DISTINCT on GQuery result set (GQL, GAE)

前端 未结 4 780
南方客
南方客 2020-12-10 16:34

Imagine you got an entity in the Google App Engine datastore, storing links for anonymous users. You would like to perform the following SQL query, which is not supported:<

4条回答
  •  伪装坚强ぢ
    2020-12-10 17:15

    Sorry to dig this question up but in GAE I cannot compare objects like that, I must use .key() for comparison like that:

    Beware, this is very inefficient :

    def unique_result(array):
        urk={} #unique results with key
        for c in array:
            if c.key() not in urwk:
                urk[str(c.key())]=c
        return urk.values()
    

    If anyone has a better solution, please share.

提交回复
热议问题