Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QByteArray not stored correctly #114

Open
yusufmk opened this issue Oct 16, 2020 · 4 comments
Open

QByteArray not stored correctly #114

yusufmk opened this issue Oct 16, 2020 · 4 comments
Assignees

Comments

@yusufmk
Copy link

yusufmk commented Oct 16, 2020

Hello, I am trying to store an image in a sqlite database.
I generate a QByteArray from pixmap. The resultant byte array has 10000 elements in it. Then I create a nut row, set image column, append new row to table and lastly save changes. None of them return any errors. The code I use is given below:

db.open();
QByteArray bArray;
QBuffer buffer(&bArray);
buffer.open(QIODevice::WriteOnly);
ui->lblGelCardImage->pixmap()->save(&buffer, "PNG");
auto newReport = Nut::create<Report>();
newReport->setImage(bArray);
// set other columns as well...
db.tblReports()->append(newReport);
bool ok = db.saveChanges();

BUT, my database doesn't increase in size AND when I try to retrieve the data back, it only returns 10 bytes. The code I use in order to retrieve the image is given below:

db.open();
QByteArray ba = db.tblReports()->query()->first().data()->Image();

Byte array "ba" only has 10 bytes of data in it. It should have contained 10000 bytes of data. What is the problem here? Am I doing something wrong? Every other column is stored and retrieved correctly.

tblReport class has the line below regarding Image field.
NUT_DECLARE_FIELD(QByteArray, Image, Image, setImage)

I used Nut version that you used in OrmTest repo. Actually that is the only version i was able to use after hours of trying. I am kinda newbie to qt.

Development platform:

  • OS: ubuntu 18.04
  • Qt creator 4.13.0, based on Qt 5.15.0
  • Compiler GCC 5.3.1
  • Nut commit hash: Commit 6ce50e2 by Jack Lilhammers, 07/07/2020 05:50 PM
  • Serializer commit hash: Commit b0194da3 by Miklós Márton, 06/13/2020 12:00 AM
@HamedMasafi
Copy link
Owner

Hi @yusufmk
Thanks for reporting
I will check it ASAP

@yusufmk
Copy link
Author

yusufmk commented Oct 20, 2020

Any update on this? pleaaaase...

@yusufmk
Copy link
Author

yusufmk commented Oct 27, 2020

Hi did you get a chance to look at this?

@HamedMasafi
Copy link
Owner

Hey @yusufmk
I will check it within few days
Thanks for your patiencion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants