Bug of "fetch_by_id_with_relation"

Open discussion on QxOrm library

Bug of "fetch_by_id_with_relation"

Postby magicu » Sat Jan 21, 2012 7:37 am

As the doc mentioned:

Parameters:
relation List of relationships keys to be fetched (eager fetch instead of default lazy fetch for a relation) : use "|" separator to put many relationships keys

I write code:
qx::dao::fetch_by_id_with_relation("type_id|admin_id", card);

But I find the implementation of the code above is:
static inline QSqlError fetchById(const QString & relation, T & t, QSqlDatabase * pDatabase)
{ return QxDao_FetchById_WithRelation<T>::fetchById((relation.isEmpty() ? QStringList() : (QStringList() << relation)), t, pDatabase); }

I think "type_id|admin_id" cann't be convert to QStringList via "QStringList() << relation". Maybe it's a bug.
magicu
 
Posts: 54
Joined: Fri Jan 20, 2012 9:51 am

Re: Bug of "fetch_by_id_with_relation"

Postby QxOrm admin » Sat Jan 21, 2012 8:47 am

Hi,

I don't think it's a bug, but it's a little tricky and there is some optimizations into the class "qx::QxSqlQueryBuilder" to keep queries into memory (a kind of cache to not have to build a query if this query has already been called).

So you will have the same behaviour with this 2 calls :
Code: Select all
qx::dao::fetch_by_id_with_relation("type_id|admin_id", card);
qx::dao::fetch_by_id_with_relation(QStringList() << "type_id" << "admin_id", card);

Maybe the second call is much easier to understand.

For more details, you can put a breakpoint into the method bool qx::IxDao_Helper::updateSqlRelationX(const QStringList & relation) : important variable is sHashRelation, you can check how it's built. You will obtain the same result with the 2 cases...
QxOrm admin
 

Re: Bug of "fetch_by_id_with_relation"

Postby magicu » Sat Jan 21, 2012 9:06 am

I get a null card->typeX and a null card->adminX using "qx::dao::fetch_by_id_with_relation("type_id|admin_id", card);"

If I modify the code to "qx::dao::fetch_by_id_with_relation("type_id", card);"
I'll get a valid card->typeX and a null card->adminX;

That is to say "|" no works.
magicu
 
Posts: 54
Joined: Fri Jan 20, 2012 9:51 am

Re: Bug of "fetch_by_id_with_relation"

Postby QxOrm admin » Sat Jan 21, 2012 9:23 am

What is the behaviour if you write :
Code: Select all
qx::dao::fetch_by_id_with_relation(QStringList() << "type_id" << "admin_id", card);
QxOrm admin
 

Re: Bug of "fetch_by_id_with_relation"

Postby magicu » Sat Jan 21, 2012 9:31 am

QxOrm admin wrote:What is the behaviour if you write :
Code: Select all
qx::dao::fetch_by_id_with_relation(QStringList() << "type_id" << "admin_id", card);



This is correct.

Just like I mentioned in the top post, "type_id|admin_id" should be splited. But I cann't find any code to do this.
magicu
 
Posts: 54
Joined: Fri Jan 20, 2012 9:51 am

Re: Bug of "fetch_by_id_with_relation"

Postby QxOrm admin » Sat Jan 21, 2012 9:32 am

Ok thanks, it will be fixed for the next release ;)
QxOrm admin
 

Re: Bug of "fetch_by_id_with_relation"

Postby QxOrm admin » Sat Jan 21, 2012 5:26 pm

I just upload a new BETA version : QxOrm 1.2.2 BETA 16.
Here is a direct link to download this BETA version : http://www.qxorm.com/version/QxOrm_1.2.2_BETA_16.zip
With this version, relationships defined with QString and using "|" should work...

If you want more informations about this BETA and new features, there is a french topic here (use google traduction if you don't understand french) :
http://www.developpez.net/forums/d11578 ... or-tester/
QxOrm admin
 

Re: Bug of "fetch_by_id_with_relation"

Postby magicu » Sun Jan 29, 2012 6:21 am

QxOrm admin wrote:I just upload a new BETA version : QxOrm 1.2.2 BETA 16.
Here is a direct link to download this BETA version : http://www.qxorm.com/version/QxOrm_1.2.2_BETA_16.zip
With this version, relationships defined with QString and using "|" should work...

If you want more informations about this BETA and new features, there is a french topic here (use google traduction if you don't understand french) :
http://www.developpez.net/forums/d11578 ... or-tester/



Well done, When is the finally version release?
magicu
 
Posts: 54
Joined: Fri Jan 20, 2012 9:51 am

Re: Bug of "fetch_by_id_with_relation"

Postby QxOrm admin » Sun Jan 29, 2012 11:17 am

QxOrm 1.2.2 has just been released ;)
QxOrm admin
 


Return to QxOrm - Open discussion

Who is online

Users browsing this forum: No registered users and 11 guests