'''
qs = Pet.select()
exp = 'id=1'
qs = filter_exp(qs, exp)
''' =>
SELECT "t1"."id", "t1"."owner_id", "t1"."name", "t1"."animal_type" FROM "pet" AS "t1" WHERE ("t1"."id" = 1)
'''
qs = Pet.select()
exp = 'owner.id>1'
qs = filter_exp(qs, exp)
'''
=>
SELECT "t1"."id", "t1"."owner_id", "t1"."name", "t1"."animal_type" FROM "pet" AS "t1" INNER JOIN "person" AS "t2" ON ("t1"."owner_id" = "t2"."id") WHERE ("t2"."id" > 1)
'''
qs = Pet.select()
u = Person.get(Person.id==1)
context = {'self': u}
exp = 'owner.id=[self]'
qs = filter_exp(qs, exp, context)
''' => SELECT "t1"."id", "t1"."owner_id", "t1"."name", "t1"."animal_type" FROM "pet" AS "t1" INNER JOIN "person" AS "t2" ON ("t1"."owner_id" = "t2"."id") WHERE ("t2"."id" = 1)
'''
qs = Pet.select()
exp = 'owner.id>1'
qs = filter_exp(qs, exp)
exp = 'id=2'
qs = filter_exp(qs, exp)
'''
=>
SELECT "t1"."id", "t1"."owner_id", "t1"."name", "t1"."animal_type" FROM "pet" AS "t1" INNER JOIN "person" AS "t2" ON ("t1"."owner_id" = "t2"."id") WHERE (("t2"."id" > 1) AND ("t1"."id" = 2))
same with filter_exp, but like this: '''
exp = 'pet:owner.id>1'
qs = filter_exp(qs, exp)
''' mean if you select table pet, must add expression "owner.id>1"