0

I have the following class relationships and I have been wondering how to use "Like" operator.

class A(db.Model):
    b = db.relationship("B")

class B(db.Model):
    info = db.Column(db.String(20))

When I contract a query as:

q={"filters": [{"name":"b__info", "op":"like", "val": "M%"}],
    ..."order_by"... "page.."}

I am given these outputs

{
     "message": "Unable to construct query"
}

If I should change "op" from "like" to "any", I won't get that error message.

Have you had any useful guidance on "like" Operator?

Thx

chfw

chfw
  • 4,502
  • 2
  • 29
  • 32

1 Answers1

0

I found this thread helpful:

https://github.com/jfinkels/flask-restless/issues/272

The solution in my case is:

q = {"filters": 
     [{"name": "b", 
       "op": "any",
       "val": {"name":"info", 
               "op":"like", 
               "val":"M%"}
      }], 
     .. "order_by"... "page"...
    }
chfw
  • 4,502
  • 2
  • 29
  • 32