Details
-
Bug
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
6.4.3
-
None
Description
I wanted to bring to your attention that there has been a change in PySide6.QtSql.QSqlQuery's behavior. When running QSqlQuery.exec(), passed parameters are no longer implicitly converted to the defined data type of the parameter. For example, in a stored procedure that takes an int parameter, passing '1' as a string no longer works and the parameter needs to be passed as an integer value instead. This change in behavior was observed in Qt 6.4.3, while in the previous version (Qt 6.4.2), it was working both ways. I am not sure if this change was intended or not, but I wanted to bring it to your attention.
run the code below in both versions:
from PySide6.QtSql import QSqlDatabase, QSqlQuery import PySide6; print(PySide6.__version__) DRIVER = "ODBC Driver 17 for SQL Server" SERVER = "your sql server instance" DATABASE = "master" db = QSqlDatabase.addDatabase("QODBC") connString = f"Driver={DRIVER};Server={SERVER};Database={DATABASE};Trusted_Connection=Yes;" db.setDatabaseName(connString) if db.open(): print('>Connected') queryObj = QSqlQuery(db) queryObj.prepare("""EXEC sp_who ?""") queryObj.addBindValue('1') # you no longer can pass int as str to a stored procedure if queryObj.exec(): while queryObj.next(): print(queryObj.value(0)) else: print(queryObj.lastError().text()) else: print(db.lastError().text())
Full output in 6.4.2
6.4.2
>Connected
1
Full output in 6.4.3
6.4.3
>Connected
QODBCResult::exec: Unable to execute statement: "[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Executing SQL directly; no cursor. [Microsoft][ODBC
Driver 17 for SQL Server][SQL Server]Conversion failed when converting the nvarchar value '1.' to data type int."
[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Executing SQL directly; no cursor. [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Conversion failed when converting the nvarchar value '1.' to data type int. QODBC: Unable to execute statement
Attachments
Issue Links
- relates to
-
QTBUG-109206 QODBC: Reading Time fails when using ODBC Driver 17 for Sql Server
- Closed