qx::QxModel strange behaviour

Forum for posting problems using QxOrm library

qx::QxModel strange behaviour

Postby asoletti » Thu Dec 12, 2019 12:28 am

Hi, I noticed an strange behaviour when using QxModel.

I have a table with the following schema

Code: Select all
CREATE TABLE brand (image_id TEXT, id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, uuid TEXT, name TEXT, created_at TEXT, updated_at TEXT)


When creating my model I used the following code:

Code: Select all
    p_model = new BrandModel(this);
    p_model->setListOfColumns(QStringList() << "id" << "name");
    p_model->qxFetchAll();


When I run my app, I noticed that the column name is not filled with data, only the column ID.

If I change the second line of method setListOfColumns with the following code:

Code: Select all
p_model->setListOfColumns(QStringList() << "name" << "id");


The model retrieve all columns and everything works just fine.

Is that a bug (the order requirement) or is the expected behaviour?
asoletti
 
Posts: 3
Joined: Sat Dec 07, 2019 8:44 am

Re: qx::QxModel strange behaviour

Postby qxorm » Fri Dec 13, 2019 8:50 am

Hello,

No I think this is not normal.
Are you able to reproduce the issue with the qxBlogModelView sample project (in ./test/ directory of QxOrm package) ?
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am

Re: qx::QxModel strange behaviour

Postby asoletti » Fri Dec 13, 2019 12:38 pm

Yes,

Change method test_qt_widget() :: main.cpp to:

Code: Select all
void test_qt_widget()
{
   qx::IxModel * pModel = new qx::QxModel<author>();
   pModel->setListOfColumns(QStringList() << "author_id" << "birthdate");
   pModel->qxFetchAll();

   QTableView tableView;
   tableView.setModel(pModel);
   tableView.setSortingEnabled(true);
   tableView.show();
   qApp->exec();
}


You will notice that the birthdate column will be empty..

Regards,
asoletti
 
Posts: 3
Joined: Sat Dec 07, 2019 8:44 am

Re: qx::QxModel strange behaviour

Postby qxorm » Mon Dec 16, 2019 2:37 pm

Hello,

Thx for the tip to reproduce the issue.
I think I have fixed it, you can test with this version : https://www.qxorm.com/version/QxOrm_1.4.7_BETA_03.zip

The problem was that id is automatically fetched (even if not in the list of columns), so adding it in the list of columns is redundant.
And when you put the id column at the end of the list, then this is ok (it is ignored actually).

Please let me know if this is ok now with QxOrm_1.4.7_BETA_03 version.
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 2 guests

cron