Closed PKLogix closed 1 year ago
Anyone to approve this change?
is_exist
contains frappe.db.exists
's return value. db.exists returns Document name (str) if a doc with mentioned conditions exists or None. The usage on L31 was faulty. I've fixed this via #57.
Fixed in another PR. Thanks anyway for pointing out and PR @PKLogix
Changes that are need are still not made please have a look at line 31 https://github.com/gavindsouza/chat/blob/a061f21943375e0be578616ee9e609720bce0204/chat/utils/__init__.py#L31
@PKLogix ah, this still seems to be present
@PKLogix ah, this still seems to be present
Yup. Thanks for reconsidering the change.
Seems related - with Frappe current develop
and guest user:
15:37:55 web.1 | Syntax error in query:
15:37:55 web.1 | SELECT `field`,`value` FROM `tabSingles` WHERE field IN (%(param1)s) AND `doctype`={'doctype': 'Chat Profile', 'token': '1997800cdc40560469ab4c80bbcaf26e555deea33f9359e6b881102b'} {'param1': 'name'}
15:37:55 web.1 | Traceback (most recent call last):
15:37:55 web.1 | File "apps/frappe/frappe/app.py", line 53, in application
15:37:55 web.1 | response = frappe.handler.handle()
15:37:55 web.1 | File "apps/frappe/frappe/handler.py", line 45, in handle
15:37:55 web.1 | data = execute_cmd(cmd)
15:37:55 web.1 | File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
15:37:55 web.1 | return frappe.call(method, **frappe.form_dict)
15:37:55 web.1 | File "apps/frappe/frappe/__init__.py", line 1605, in call
15:37:55 web.1 | return fn(*args, **newargs)
15:37:55 web.1 | File "apps/frappe/frappe/__init__.py", line 728, in wrapper
15:37:55 web.1 | return func(*args, **kwargs)
15:37:55 web.1 | File "apps/chat/chat/api/config.py", line 29, in settings
15:37:55 web.1 | token_verify = validate_token(token)
15:37:55 web.1 | File "apps/chat/chat/utils/__init__.py", line 23, in validate_token
15:37:55 web.1 | chat_profile = frappe.db.get_value({
15:37:55 web.1 | File "apps/frappe/frappe/database/database.py", line 456, in get_value
15:37:55 web.1 | result = self.get_values(
15:37:55 web.1 | File "apps/frappe/frappe/database/database.py", line 580, in get_values
15:37:55 web.1 | out = self.get_values_from_single(
15:37:55 web.1 | File "apps/frappe/frappe/database/database.py", line 623, in get_values_from_single
15:37:55 web.1 | r = frappe.qb.engine.get_query(
15:37:55 web.1 | File "apps/frappe/frappe/query_builder/utils.py", line 86, in execute_query
15:37:55 web.1 | return frappe.db.sql(query, params, *args, **kwargs) # nosemgrep
15:37:55 web.1 | File "apps/frappe/frappe/database/database.py", line 219, in sql
15:37:55 web.1 | self._cursor.execute(query, values)
15:37:55 web.1 | File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 148, in execute
15:37:55 web.1 | result = self._query(query)
15:37:55 web.1 | File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 310, in _query
15:37:55 web.1 | conn.query(q)
15:37:55 web.1 | File "env/lib/python3.10/site-packages/pymysql/connections.py", line 548, in query
15:37:55 web.1 | self._affected_rows = self._read_query_result(unbuffered=unbuffered)
15:37:55 web.1 | File "env/lib/python3.10/site-packages/pymysql/connections.py", line 775, in _read_query_result
15:37:55 web.1 | result.read()
15:37:55 web.1 | File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1156, in read
15:37:55 web.1 | first_packet = self.connection._read_packet()
15:37:55 web.1 | File "env/lib/python3.10/site-packages/pymysql/connections.py", line 725, in _read_packet
15:37:55 web.1 | packet.raise_for_error()
15:37:55 web.1 | File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
15:37:55 web.1 | err.raise_mysql_exception(self._data)
15:37:55 web.1 | File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
15:37:55 web.1 | raise errorclass(errno, errval)
15:37:55 web.1 | 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 ''doctype': 'Chat Profile', 'token': '1997800cdc40560469ab4c80bbcaf26e555deea3...' at line 1")
frappe.db.is_exit dont return any record because it only returns bolean. We cannot use it as reference to get a chat profile document. Thats why when ever this function is called application gives error: Wrong line: guest_user = frappe.get_doc(‘Chat Profile’, str(is_exist[0][0]))