Nut icon indicating copy to clipboard operation
Nut copied to clipboard

unstable inserting or updating fields=false in release

Open Styletto opened this issue 2 years ago • 1 comments

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<Post>(); 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:

  • OS: Win11 x64, Kubuntu 22.04
  • Qt version: QtTest library 6.2.4
  • Compiler: mingw_64 (GCC 11.2.0), MSVC2019 (VS 2022), G++-11 (Kubuntu)

No errors in Debug versions!!

linux-tests.zip windows-test.zip

Styletto avatar Jul 07 '22 23:07 Styletto

Hi @Styletto Thanks for reporting

I'll check it as soon as possible

HamedMasafi avatar Jul 08 '22 07:07 HamedMasafi