diff --git a/.gitignore b/.gitignore index 39821c1..f821c6c 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ *build* .vscode .cache +/.vs +/CMakeSettings.json diff --git a/ormpp/utility.hpp b/ormpp/utility.hpp index 02d9b3a..dd09e3e 100644 --- a/ormpp/utility.hpp +++ b/ormpp/utility.hpp @@ -4,6 +4,7 @@ #ifndef ORM_UTILITY_HPP #define ORM_UTILITY_HPP #include +#include #include "entity.hpp" #include "iguana/reflection.hpp" @@ -440,15 +441,17 @@ inline void get_sql_conditions(std::string &) {} template inline void get_sql_conditions(std::string &sql, const std::string &arg, Args &&...args) { - if (arg.find("select") != std::string::npos) { + std::string temp=arg; + std::transform(arg.begin(),arg.end(),temp.begin(),::tolower); + if (temp.find("select") != std::string::npos) { sql = arg; } else { - if (arg.find("order by") != std::string::npos) { + if (temp.find("order by") != std::string::npos) { auto pos = sql.find("where"); sql = sql.substr(0, pos); } - if (arg.find("limit") != std::string::npos) { + if (temp.find("limit") != std::string::npos) { auto pos = sql.find("where"); sql = sql.substr(0, pos); } diff --git a/tests/test_ormpp.cpp b/tests/test_ormpp.cpp index db31d9a..d99f66a 100644 --- a/tests/test_ormpp.cpp +++ b/tests/test_ormpp.cpp @@ -1392,6 +1392,8 @@ TEST_CASE("query_s delete_records_s") { auto vec5 = sqlite.query_s("name=? and age=?", "purecpp", 200); auto vec6 = sqlite.query_s("select * from person where name=?", "purecpp"); + auto vec11 = + sqlite.query_s("SELECT * FROM PERSON WHERE NAME=?", "purecpp"); auto vec7 = sqlite.query_s("name=?", "purecpp' or '1=1"); sqlite.delete_records_s("name=?", "purecpp' or '1=1"); auto vec8 = sqlite.query_s(); @@ -1415,6 +1417,7 @@ TEST_CASE("query_s delete_records_s") { CHECK(vec8.size() == 2); CHECK(vec9.size() == 1); CHECK(vec10.size() == 0); + CHECK(vec11.front().age == 200); } #endif }