python - GQL: Not equal filter on a multivalued property -
tinkering little gae's datastore i've found can't think proper way filter out results using inequality filter '!=' on multivalued property:
class entry(db.model): ... tags = db.stringlistproperty() e1 = entry() e2 = entry() e1.tags = ['tag1', 'tag2', 'tag3'] e2.tags = ['tag1', 'tag3', 'tag4'] # want exclude results containing 'tag2' db.gqlquery("""select * entry tags != 'tag2' """)
the problem query returns both e1 , e2 want e2.
i think happens because inequality filter evaluates (true if @ least 1 value != 'tag2'. there's way apply filter all? (true if values != 'tag2')?
i know gae's datastore not relational i'd know how cleverly solve/think kind of queries.
thanks ;)
i've thought bunch , don't think there way (please correct me if i'm wrong). non-clever solution not use stringlistproperty , cascade bunch of filters:
class entry(db.model): ... tag_1 = db.stringproperty(); tag_2 = db.stringproperty(); ... entry.all().filter('tag_1 !=', tag).filter('tag_2 !=', tag) ...
i'm not going begin describe obvious problems solution, @ least want.
Comments
Post a Comment