ponyorm / pony

Pony Object Relational Mapper
Apache License 2.0
3.65k stars 245 forks source link

SQL Syntax Error for JSON query on mariadb #548

Open Berserker66 opened 4 years ago

Berserker66 commented 4 years ago
[2020-08-18 01:31:53,419] UPDATE `generation`
SET `state` = %s
WHERE `id` = %s
  AND `owner` = %s
  AND (`options` = CAST(%s AS JSON))
  AND (`meta` = CAST(%s AS JSON))
  AND `state` = %s
[2020-08-18 01:31:53,420] ROLLBACK
[2020-08-18 01:31:53,420] RELEASE CONNECTION
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pony/orm/dbapiprovider.py", line 52, in wrap_dbapi_exceptions
    return func(provider, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/pony/orm/dbapiprovider.py", line 279, in execute
    else: cursor.execute(sql, arguments)
  File "/usr/local/lib/python3.8/dist-packages/pymysql/cursors.py", line 163, in execute
    result = self._query(query)
  File "/usr/local/lib/python3.8/dist-packages/pymysql/cursors.py", line 321, in _query
    conn.query(q)
  File "/usr/local/lib/python3.8/dist-packages/pymysql/connections.py", line 505, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/usr/local/lib/python3.8/dist-packages/pymysql/connections.py", line 724, in _read_query_result
    result.read()
  File "/usr/local/lib/python3.8/dist-packages/pymysql/connections.py", line 1069, in read
    first_packet = self.connection._read_packet()
  File "/usr/local/lib/python3.8/dist-packages/pymysql/connections.py", line 676, in _read_packet
    packet.raise_for_error()
  File "/usr/local/lib/python3.8/dist-packages/pymysql/protocol.py", line 223, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/usr/local/lib/python3.8/dist-packages/pymysql/err.py", line 107, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (1064, 'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'JSON))\n  AND (`meta` = CAST(\'{\\"race\\": false, \\"owner\\": 2888536338322307754256\' at line 5')

Seems to be the launch_generator function in https://github.com/Berserker66/MultiWorld-Utilities/blob/master/WebHostLib/autolauncher.py that triggers it. Works fine on SQLite and then breaks when I pushed to production that runs mariadb

dlenski commented 8 months ago

Duplicate of #270?