Page 1 of 1

Bug of "fetch_by_id_with_relation"

PostPosted: Sat Jan 21, 2012 7:37 am
by magicu
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.

Re: Bug of "fetch_by_id_with_relation"

PostPosted: Sat Jan 21, 2012 8:47 am
by QxOrm admin
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...

Re: Bug of "fetch_by_id_with_relation"

PostPosted: Sat Jan 21, 2012 9:06 am
by magicu
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.

Re: Bug of "fetch_by_id_with_relation"

PostPosted: Sat Jan 21, 2012 9:23 am
by QxOrm admin
What is the behaviour if you write :
Code: Select all
qx::dao::fetch_by_id_with_relation(QStringList() << "type_id" << "admin_id", card);

Re: Bug of "fetch_by_id_with_relation"

PostPosted: Sat Jan 21, 2012 9:31 am
by magicu
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.

Re: Bug of "fetch_by_id_with_relation"

PostPosted: Sat Jan 21, 2012 9:32 am
by QxOrm admin
Ok thanks, it will be fixed for the next release ;)

Re: Bug of "fetch_by_id_with_relation"

PostPosted: Sat Jan 21, 2012 5:26 pm
by QxOrm admin
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/

Re: Bug of "fetch_by_id_with_relation"

PostPosted: Sun Jan 29, 2012 6:21 am
by magicu
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?

Re: Bug of "fetch_by_id_with_relation"

PostPosted: Sun Jan 29, 2012 11:17 am
by QxOrm admin
QxOrm 1.2.2 has just been released ;)