Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

mysql: fix SELECT queries containing "CAST(foo as integer)" (fixes #1…

…4496)
  • Loading branch information...
commit ef7dffba042c4dcde3ac03aa8b4b7f874ff8a85d 1 parent ab8b165
@Montellese Montellese authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 xbmc/dbwrappers/mysqldataset.cpp
View
8 xbmc/dbwrappers/mysqldataset.cpp
@@ -1403,9 +1403,15 @@ bool MysqlDataset::query(const char *query) {
close();
+ size_t loc;
+
+ // mysql doesn't understand CAST(foo as integer) => change to CAST(foo as signed integer)
+ if ((loc = ci_find(qry, "as integer)")) != string::npos)
+ qry = qry.insert(loc + 3, "signed ");
+
MYSQL_RES *stmt = NULL;
- if ( static_cast<MysqlDatabase*>(db)->setErr(static_cast<MysqlDatabase*>(db)->query_with_reconnect(query), query) != MYSQL_OK )
+ if ( static_cast<MysqlDatabase*>(db)->setErr(static_cast<MysqlDatabase*>(db)->query_with_reconnect(qry.c_str()), qry.c_str()) != MYSQL_OK )
throw DbErrors(db->getErrorMsg());
MYSQL* conn = handle();
Please sign in to comment.
Something went wrong with that request. Please try again.