Page 1 of 1

qx::QxModel strange behaviour

PostPosted: Thu Dec 12, 2019 12:28 am
by asoletti
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?

Re: qx::QxModel strange behaviour

PostPosted: Fri Dec 13, 2019 8:50 am
by qxorm
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) ?

Re: qx::QxModel strange behaviour

PostPosted: Fri Dec 13, 2019 12:38 pm
by asoletti
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,

Re: qx::QxModel strange behaviour

PostPosted: Mon Dec 16, 2019 2:37 pm
by qxorm
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.