feat(AbstractDb): add a noLimitValue function to deal with LIMIT keyword properly

This commit is contained in:
Ronan Abhamon 2017-12-15 10:48:47 +01:00
parent de04087a34
commit 4cdb46496e
3 changed files with 17 additions and 1 deletions

View file

@ -137,6 +137,20 @@ string AbstractDb::timestampType () const {
return "";
}
string AbstractDb::noLimitValue () const {
L_D();
switch (d->backend) {
case Mysql:
return "9999999999999999999";
case Sqlite3:
return "-1";
}
L_ASSERT(false);
return "";
}
long long AbstractDb::getLastInsertId () const {
long long id = 0;

View file

@ -56,6 +56,8 @@ protected:
std::string timestampType () const;
std::string noLimitValue () const;
long long getLastInsertId () const;
void enableForeignKeys (bool status);

View file

@ -1883,7 +1883,7 @@ static constexpr string &blobToString (string &in) {
if (end > 0)
query += " LIMIT " + Utils::toString(end - begin);
else
query += " LIMIT 9999999999999999999"; // For Mysql compatibility, do not set -1.
query += " LIMIT " + noLimitValue();
if (begin > 0)
query += " OFFSET " + Utils::toString(begin);