Description:
Doesn't seem to parse correctly the expression.
Error:
Traceback (most recent call last):
File "test.py", line 24, in <module>
.bind('{"country": "Mexico", "gnp": 12345}') \
File "/usr/local/lib/python2.7/dist-packages/mysqlx/statement.py", line 516, in execute
return self._connection.find(self)
File "/usr/local/lib/python2.7/dist-packages/mysqlx/connection.py", line 123, in wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/mysqlx/connection.py", line 201, in find
return DocResult(self) if statement._doc_based else RowResult(self)
File "/usr/local/lib/python2.7/dist-packages/mysqlx/result.py", line 834, in __init__
super(DocResult, self).__init__(connection)
File "/usr/local/lib/python2.7/dist-packages/mysqlx/result.py", line 706, in __init__
self._init_result()
File "/usr/local/lib/python2.7/dist-packages/mysqlx/result.py", line 709, in _init_result
self._columns = self._connection.get_column_metadata(self)
File "/usr/local/lib/python2.7/dist-packages/mysqlx/connection.py", line 123, in wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/mysqlx/connection.py", line 242, in get_column_metadata
return self.protocol.get_column_metadata(result)
File "/usr/local/lib/python2.7/dist-packages/mysqlx/protocol.py", line 318, in get_column_metadata
msg = self._read_message(rs)
File "/usr/local/lib/python2.7/dist-packages/mysqlx/protocol.py", line 302, in _read_message
raise OperationalError(msg.msg)
mysqlx.errors.OperationalError: Invalid operator AND
How to repeat:
'''
Using:
* Python: 2.7.12
* MySQL: 5.7.17
* Schema: world_x http://downloads.mysql.com/docs/world_x-db.zip
* Connector/Python: 2.2.2 m3 https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.2.2.tar.gz
'''
import os
import mysqlx
import string
session = mysqlx.get_session({
'host': 'localhost',
'port': 33060,
'user': os.environ['user'],
'password': os.environ['password']
})
schema = session.get_schema('world_x')
collection = schema.get_collection('countryinfo')
''' Work
print "Find Mexico***\n"
result = collection.find('Name = :country') \
.bind('{ "country": "Mexico" }') \
.execute()
'''
# Not work
result = collection.find('Name = :country and GNP = :gnp') \
.bind('{ "country": "Mexico", "gnp": 414972 }') \
.execute()
row = result.fetch_all()
for i, data in enumerate(row):
print "{iteration}: {data}".format(iteration = i, data = data)
session.close()