Page 1 of 1

QxSession::fetchById results in Parameter count mismatch

PostPosted: Sun Apr 27, 2014 3:04 pm
by shaan7
I have a templated method for convenience that fetches items from the db like this (id is a QString) -

Code: Select all
QSharedPointer<T> item = QSharedPointer<T>(new T(id));
qx::dao::fetch_by_id(item);


which results in this (T = Artist) -

Code: Select all
[QxOrm] 'qx::dao' internal error <fetch by id> : SELECT Artist.name AS Artist_name_0 FROM Artist WHERE Artist.name = :name
[QxOrm] sql query returns no data


This is expected, as the table is actually empty. However, if I use QxSession::fetchById instead-

Code: Select all
qx::QxSession session;
QSharedPointer<T> item = QSharedPointer<T>(session.fetchById<T>(id));


I get this (T = Artist) -

Code: Select all
[QxOrm] execute sql query failed : SELECT Artist.name AS Artist_name_0 FROM Artist WHERE Artist.name = :name
Parameter count mismatch


Now, the queries in both the cases look like the same SQL query, so probably something is wrong with :name. How do I debug this?

Re: QxSession::fetchById results in Parameter count mismatch

PostPosted: Sun Apr 27, 2014 5:24 pm
by qxorm
Hi,

Strange because session.fetchById<T>() will call exactly the same code ==> qx::dao::fetch_by_id()

Could you please provide your qx::register_class<Artist>() function ?
Then I will try to reproduce your problem...

Re: QxSession::fetchById results in Parameter count mismatch

PostPosted: Sun Apr 27, 2014 7:20 pm
by shaan7
qxorm wrote:Strange because session.fetchById<T>() will call exactly the same code ==> qx::dao::fetch_by_id()


Exactly, I even put few qDebugs in the fetch_by_id code, the id looks to be set correctly.
Anyway, here's the register_class function https://projects.kde.org/projects/extra ... st.cpp#L28

Re: QxSession::fetchById results in Parameter count mismatch

PostPosted: Mon Apr 28, 2014 11:01 am
by qxorm
Sorry but I'm not able to reproduce it !

qx::dao::fetch_by_id<T>() and session.fetchById<T>() give me exactly the same result :
Code: Select all
[QxOrm] 'qx::dao' internal error <fetch by id> : SELECT author.author_id AS author_author_id_0 FROM author WHERE author.author_id = :author_id
[QxOrm] sql query returns no data


Could you try to reproduce it using qxBlog sample project in ./test/ directory of QxOrm package please ?
The author class seems to be equivalent to your Artist class.

But I really don't know what could happen in your case because session.fetchById<T>() calls exactly the same code as qx::dao::fetch_by_id<T>() => so really strange !
Are you sure you have clean all (QxOrm lib + your project) and rebuild all (QxOrm lib + your project) ?