HamedMasafi / Nut

Advanced, Powerful and easy to use ORM for Qt
GNU Lesser General Public License v3.0
294 stars 75 forks source link

unstable inserting or updating fields=false in release #127

Open Styletto opened 2 years ago

Styletto commented 2 years ago

Unstable updating of fields equal to false in release. I have tested tst_benchmark with a little sophisticated code. Tested MySql, SQLite3 in kubuntu, win11 (mscvc 2019, VS 2022 and mingw64). The errors are the same. Stored value may be NULL or 0 (NULL or false in SQLite) if value to store or update equal to false. No errors in Debug versions.

Steps to reproduce the behavior:

  1. Change some code from tst_benchmark.cpp

void BenchmarkTest::insert1kPost() { QElapsedTimer t; t.start(); for (int i = 0; i < 1000; ++i) { auto newPost = Nut::create(); auto number = ' ' + QString::number(i + 1); newPost->setTitle(QStringLiteral("post title") + number); newPost->setBody(QStringLiteral("post body") + number); (i % 2) == 0 ? newPost->setPublic(false) : newPost->setPublic(true); newPost->setSaveDate(QDateTime::currentDateTime()); db.posts()->append(newPost); } db.saveChanges(); qDebug("1k post inserted in %lld ms", t.elapsed()); }

Field isPublic each even record of table "posts" should contain 'true' (or 1 in mysql) and and so it is. The fields of odd records should contain 'false" (or 0 in mysql) but this is not always the case. NULL not equal to false therefore, an execution error or logic error occurs. Similar behavior when updating to 'false' the bool field equal to "true" (1). All files and screenshot from 2 OS each 2 drivers (QSQLITE, QMYSQL) attached. Development platform:

No errors in Debug versions!!

linux-tests.zip windows-test.zip

HamedMasafi commented 2 years ago

Hi @Styletto Thanks for reporting

I'll check it as soon as possible