Search code examples
python-2.7google-cloud-platformgoogle-cloud-datastoregql

Parse Error: Invalid WHERE Identifier at symbol (


I am trying to get a result using an optional parameters.

result = Tester.gql("WHERE (first_name IS NULL OR first_name = :first_name)"
                                "AND (last_name IS NULL OR last_name = :last_name)"
                                "AND (birth_date IS NULL OR birth_date = :birth_date)"
                                "AND (test_voucher IS NULL OR test_voucher = :test_voucher)", first_name=first_name,
                                last_name=last_name, birth_date=birth_date, test_voucher=test_voucher)

However, I am getting an error about parsing when I use this GQL script.

{
    "error": {
        "message": "Parse Error: Invalid WHERE Identifier at symbol ("
    }
}

I am trying to figure out what is wrong in my GQL script. Thanks in advance


Solution

  • I don't think that's valid GQL:

    • there is no mentioning of using '(' and ')' for compound conditions (which is what I belive the error you see is about), the only valid condition constructs are (from GQL Reference):

      [ WHERE <compound-condition> ]
      
      <compound-condition> := <condition>+AND
      
      <condition> :=
        <property-name> IS NULL
      | <property-name> <forward-comparator> <value>
      | <value> <backward-comparator> <property-name>
      
    • there is no OR operator in GQL, so there is no need for grouping, see In Google DataStore GQL, how can I group the WHERE terms? (also complaining about parentheses)