QxSession::fetchById results in Parameter count mismatch

Forum for posting problems using QxOrm library

QxSession::fetchById results in Parameter count mismatch

Postby shaan7 » Sun Apr 27, 2014 3:04 pm

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?
shaan7
 
Posts: 3
Joined: Sun Apr 27, 2014 2:59 pm

Re: QxSession::fetchById results in Parameter count mismatch

Postby qxorm » Sun Apr 27, 2014 5:24 pm

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...
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am

Re: QxSession::fetchById results in Parameter count mismatch

Postby shaan7 » Sun Apr 27, 2014 7:20 pm

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
shaan7
 
Posts: 3
Joined: Sun Apr 27, 2014 2:59 pm

Re: QxSession::fetchById results in Parameter count mismatch

Postby qxorm » Mon Apr 28, 2014 11:01 am

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) ?
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 6 guests

cron