API: Make query and table objects independent of connection (decouple)
ClosedPublic

Authored by staniek on Aug 1 2017, 8:19 AM.

Details

Summary

So far table and query schema objects had connection pointer attached to them. There are issues with that:

  • the connetion pointer was not always present (depends on constructor)
  • connection needs to be created/accessible first, then the table/schema objects can be created
  • lifetime problem: by closing the connection there can be hanging pointers to the connection

This patch changes very little of functionality, mostly the API is altered. Connection pointer is now supplied when needed (eg. KDbQuerySchema::field, KDbQuerySchema::columnInfo). Query objects now cache their column information in context of connection. As soon as connection object changes, the cache is updated on next access.

Changes less related to the main topic but affecting the same classes are added:
+ use enum class instead of enums
+ because connection context is needed for query or table, QDebug operator now needs it too so std::tuple is used
+ move recordCount() to KDbConnection
+ fix parser when query object is pre-allocated
+ cache expanded fields of KDbQuerySchema in context of connection
+ side effect: the expanded field cache now uses less pointers so many checks for null pointers and and operator-new calls have been removed from KDbQuerySchema
+ add QuerySchemaTest: test if expanded fields cache is updated when query schema object changes
+ add more const overloads

FIXED-IN:3.1.0

Test Plan

Run all autotests, run Kexi - try tables/queries/forms/reports in data and design view.
Check if scripts work.

Diff Detail

Repository
R15 KDb
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
staniek created this revision.Aug 1 2017, 8:19 AM
Restricted Application added a project: KDb. · View Herald TranscriptAug 1 2017, 8:19 AM
staniek updated this revision to Diff 17497.Aug 1 2017, 1:37 PM
  • Cache expanded fields of KDbQuerySchema in context of connection
  • GIT_SILENT KDbParser::query const overload makes no sense - remove
staniek edited the summary of this revision. (Show Details)Aug 1 2017, 1:40 PM
staniek updated this revision to Diff 17516.Aug 1 2017, 7:38 PM
  • TRIVIAL remove test plans for nonexistent APIs
  • GIT_SILENT move metatype declarations from kdbtest to kdbtestutils
  • Add QuerySchemaTest: test if expanded fields cache is updated when query schema object changes
staniek edited the summary of this revision. (Show Details)Aug 1 2017, 7:39 PM
staniek edited the summary of this revision. (Show Details)Aug 1 2017, 8:54 PM
piggz accepted this revision.Aug 8 2017, 6:32 PM

Just one question, what is the context where the connection related to a query schema is dynamic?

This revision is now accepted and ready to land.Aug 8 2017, 6:32 PM
This revision was automatically updated to reflect the committed changes.