QVariant DB Persist

Open discussion on QxOrm library

QVariant DB Persist

Postby Kasuax » Tue Apr 11, 2017 3:35 pm

I need to switch the internal mechanisms that serialize QVariants to the database from XML to Binary.
We are vary heavy on QVariants and I feel a switch like this might buy us some time savings.

Is there a flag I can set somewhere?

Thanks,
-Stephen
Kasuax
 
Posts: 62
Joined: Mon Jun 20, 2016 6:42 pm

Re: QVariant DB Persist

Postby qxorm » Tue Apr 18, 2017 7:58 am

Hello,

No there is no runtime flag.
But if you doesn't enable boost XML serialization compilation option, then the binary serialization will be used.
qxorm
Site Admin
 
Posts: 483
Joined: Mon Apr 12, 2010 7:45 am

Re: QVariant DB Persist

Postby Kasuax » Thu Apr 20, 2017 3:58 pm

Excellent I will try this!
Thank you!
Kasuax
 
Posts: 62
Joined: Mon Jun 20, 2016 6:42 pm

Re: QVariant DB Persist

Postby Kasuax » Tue Apr 25, 2017 4:12 am

I'm having some unexpected difficulty with this.
The only thing I did was disable XML in the QxOrm.pri

I'm trying to write out the following QVariant type and it's failing to generate the sql insert statement correctly.

Let me know what you think. Thanks!

Code: Select all
typedef QPair<QString, QVariant> Option;
typedef QList<Option> OptionsList;


Code: Select all
    QXC::OptionsList samplingRates;
    samplingRates.append(QXC::Option(QString("12.5hz"), 12.5));
    samplingRates.append(QXC::Option(QString("25hz"), 25.0));
    samplingRates.append(QXC::Option(QString("50hz"), 50.0));
    samplingRates.append(QXC::Option(QString("100hz"), 100.0));
    samplingRates.append(QXC::Option(QString("200hz"), 200.0));
    samplingRates.append(QXC::Option(QString("400hz"), 400.0));
    samplingRates.append(QXC::Option(QString("800hz"), 800.0));

    settings->setSamplingRates(samplingRates);


Code: Select all
WARNING:  nonstandard use of \\ in a string literal
LINE 1: SELECT '\\' x
               ^
HINT:  Use the escape string syntax for backslashes, e.g., E'\\'.
WARNING:  nonstandard use of \\ in a string literal
LINE 1: SELECT '\\' x
               ^
Kasuax
 
Posts: 62
Joined: Mon Jun 20, 2016 6:42 pm

Re: QVariant DB Persist

Postby qxorm » Tue Apr 25, 2017 10:24 am

I don't see the call which generate the SQL query.
How do you build your SQL query ? Could you please share this code ?
qxorm
Site Admin
 
Posts: 483
Joined: Mon Apr 12, 2010 7:45 am

Re: QVariant DB Persist

Postby Kasuax » Tue Apr 25, 2017 4:09 pm

I don't build the query, the entity editor and framework build the query for me. I'm wondering if I'm not correctly mapping types in the entity editor. Since this is ultimately a variable blob of text I set the field as a TEXT in postgres. But if it's encoded as a binary blob should I represent that somehow else via the editor?
Kasuax
 
Posts: 62
Joined: Mon Jun 20, 2016 6:42 pm

Re: QVariant DB Persist

Postby qxorm » Wed Apr 26, 2017 5:51 pm

I don't understand your issue and I'm not able to reproduce it.
Do you have this error when you call this line : settings->setSamplingRates(samplingRates); ?
qxorm
Site Admin
 
Posts: 483
Joined: Mon Apr 12, 2010 7:45 am

Re: QVariant DB Persist

Postby Kasuax » Wed Apr 26, 2017 7:18 pm

The class that exhibits this structure is failing to insert into my db when i try save it.
I think the problem has something to do with expect types. This "Options" class when broken down into a binary blob might be picking the wrong sql param method when it goes to do the insert. The problem is definitely with the insert sql statement and facilitating parameter. The insert statement looks clean but I'm not sure the value bind is taking the correct approach.

This was just 1 way to do this as per your example.
Code: Select all
qx::QxSqlQuery query("WHERE author.sex = :sex");
query.bind(":sex", author::female);


I'll see what else I can dig up.
Thanks
Kasuax
 
Posts: 62
Joined: Mon Jun 20, 2016 6:42 pm

Re: QVariant DB Persist

Postby qxorm » Thu Apr 27, 2017 12:41 pm

What is your database ?
Maybe the problem comes from the placeholder type : instead of :sex, maybe it should be '?' ?
You can change it with the function : qx::QxSqlDatabase::getSingleton()->setSqlPlaceHolderStyle()
More details in the manual here : https://www.qxorm.com/qxorm_en/manual.html#manual_3600
qxorm
Site Admin
 
Posts: 483
Joined: Mon Apr 12, 2010 7:45 am

Re: QVariant DB Persist

Postby Kasuax » Thu Apr 27, 2017 6:20 pm

We are using postgres.
I'll look into this thank you!
Kasuax
 
Posts: 62
Joined: Mon Jun 20, 2016 6:42 pm


Return to QxOrm - Open discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron