Kexi: Do not switch to Data View if fetching records failed, show clear message
ClosedPublic

Authored by staniek on Dec 31 2015, 10:53 AM.

Details

Summary

In particular this covers the cases:

  • reserved word used for table name (we're not supporting it in Kexi 2.x, see bug 356888 and example attached there)
  • reserved word used for field name (we're not supporting it in Kexi 2.x, see bug 357025 and example attached there)
  • any data fetching errors
  • all the above is supported not only for tables (as the bug report suggests) but also for queries, forms, reports, csv export
  • a few API changes were required for reports

Also display better error message; in addition to "Opening object "cast" failed. Switching to other view failed (Data View)." this is displayed in the details (examples):

  • "Error opening database cursor. near ".": syntax error"
  • exact SQL statement

BUG:356888
FIXED-IN:2.9.11

Test Plan

Open the 356888-Test01.kexi file attached at https://bugs.kde.org/show_bug.cgi?id=356888#attach_96375 and test the following:

  • open the 'cast' table in data view mode
  • open the 'cast' query in data view mode
  • open the 'cast' form in data view mode
  • open the 'cast' report in data view mode
  • right-click the 'cast' table and pick Export -> To Clipboard
  • right-click the 'cast' table and pick Export -> To File...

In all these cases error like this should appear:
"Opening object "cast" failed. Switching to other view failed (Data View)
Error opening database cursor. near ".": syntax error
SQL statement: SELECT movies_id, person_id, id, cast.OID FROM cast ORDER BY id"

And Kexi should refuse opening the data view.

Also opeining any of these objects in design view works. Then Kexi should not allow to switch to data view, displaying the same error.

Diff Detail

Repository
R8 Calligra
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
staniek updated this revision to Diff 1677.Dec 31 2015, 10:53 AM
staniek retitled this revision from to Kexi: Do not switch to Data View if fetching records failed, show clear message.
staniek updated this object.
staniek edited the test plan for this revision. (Show Details)
staniek added a reviewer: piggz.
staniek added a subscriber: Kexi-Devel-list.
piggz added inline comments.Dec 31 2015, 1:33 PM
kexi/core/KexiView.cpp
559

nothing is being set here ... suggest alternate name?

kexi/plugins/forms/kexiformview.cpp
727

add some {} ?

Just found a regression: error in KexiFormView::initDataSource() when data source is not set. But it manifests only with this patch, before we've been just ignoring failures.

/me dreaming about autotests for all this machinery..

kexi/core/KexiView.cpp
559

Probably but the purpose of the method is to really set data to the 'data widget' - you can see that easily in the KexiDataTableView::setWidgetData() implementation. The cursor->open() default is just sufficient for forms and reports.

kexi/plugins/forms/kexiformview.cpp
727

Yes, originally I did but decided to keep the patch minimal/ready to study for now.

staniek updated this revision to Diff 1681.Dec 31 2015, 3:19 PM
staniek updated this revision to Diff 1682.Dec 31 2015, 3:22 PM

Reports: Fix ownership of ORODocument, this fixes crash for reports without data source

@piggz All know issues fixed, ready to test!

piggz edited edge metadata.Jan 2 2016, 10:18 AM

tested on branch 2.9, seems ok

This revision was automatically updated to reflect the committed changes.