Adding params in exception output and check exception message with is search instead of find expression (#465)

This commit is contained in:
bizmate 2022-12-01 10:50:42 +04:00
commit 70efd0f43c
2 changed files with 6 additions and 3 deletions

View file

@ -725,7 +725,8 @@ def privileges_grant(cursor, user, host, db_table, priv, tls_requires, maria_rol
try: try:
cursor.execute(query, params) cursor.execute(query, params)
except (mysql_driver.ProgrammingError, mysql_driver.OperationalError, mysql_driver.InternalError) as e: except (mysql_driver.ProgrammingError, mysql_driver.OperationalError, mysql_driver.InternalError) as e:
raise InvalidPrivsError("Error granting privileges, invalid priv string: %s , query: %s , exception: %s." % (priv_string, query, str(e))) raise InvalidPrivsError("Error granting privileges, invalid priv string: %s , params: %s, query: %s ,"
" exception: %s." % (priv_string, str(params), query, str(e)))
def convert_priv_dict_to_str(priv): def convert_priv_dict_to_str(priv):

View file

@ -40,5 +40,7 @@
assert: assert:
that: that:
- result is failed - result is failed
- result.msg.find('exception') != -1 - result.msg is search('invalid priv string')
fail_msg: "Error granting privileges, invalid priv string: SELECT , query: GRANT SELECT ON *.`data` TO %s@%s , exception: (1064, \"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`data` TO 'db_user2'@'localhost'' at line 1\")." - result.msg is search('params')
- result.msg is search('query')
- result.msg is search('exception')