Diffusion KDb aa2a7a43b0a1

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

Authored by staniek on Aug 1 2017, 7:38 PM.

Description

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

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.

Reviewers: piggz

Reviewed By: piggz

Tags: KDb

Maniphest Tasks: T6695

Differential Revision: https://phabricator.kde.org/D7027

Merged Changes

CommitAuthorDetailsCommitted
09c0b84e611aD7027staniek
Add QuerySchemaTest: test if expanded fields cache is updated when query schema… 
Aug 1 2017
dae760aa157aD7027staniek
GIT_SILENT move metatype declarations from kdbtest to kdbtestutils 
Aug 1 2017
372d13cb2384D7027staniek
TRIVIAL remove test plans for nonexistent APIs 
Aug 1 2017
4fb850d6d2e9D7027staniek
GIT_SILENT KDbParser::query const overload makes no sense - remove 
Aug 1 2017
e755e3af2ca9D7027staniek
Cache expanded fields of KDbQuerySchema in context of connection 
Aug 1 2017
3e87811cfd5aD7027staniek
API: Make query and table objects independent of connection (decouple) 
Aug 1 2017