DbTableDataProvider.qc.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// minimum required Qore version
// assume local scope for variables, do not use "$" signs
// require type definitions everywhere
// enable all warnings
namespace DbDataProvider {
class DbTableDataProvider : public AbstractDataProvider {
public:
const ProviderInfo = <DataProviderInfo>{
"type": "DbTableDataProvider",
"supports_read": True,
"supports_create": True,
"supports_update": True,
"supports_upsert": True,
"supports_delete": True,
"supports_native_search": True,
"supports_bulk_read": True,
"supports_bulk_create": True,
"supports_bulk_upsert": True,
"supports_children": False,
"constructor_options": ConstructorOptions,
"search_options": SearchOptions,
"create_options": CreateOptions,
"upsert_options": UpsertOptions,
"transaction_management": True,
"has_record": True,
"mapper_keys": MapperKeyInfo,
};
const MapperKeyInfo = Mapper::MapperKeyInfo + {
"sequence": <MapperRuntimeKeyInfo>{
"desc": "names the DB sequence that will be used to populate the field",
"value_type": "string",
"unique_roles": "*",
"returns_type": "int",
},
"sequence_currval": <MapperRuntimeKeyInfo>{
"desc": "names the DB sequence that will be used to populate the field; the current value of the "
"sequence is used; will not increment the sequence",
"value_type": "string",
"unique_roles": "*",
"returns_type": "int",
},
};
const ConstructorOptions = {
"datasource": <DataProviderOptionInfo>{
"type": (
AbstractDataProviderType::get(StringType),
AbstractDataProviderType::get(new Type("AbstractDatasource")),
),
"desc": "the datasource connection string or an abstract datasource object; in case a connection "
"string is given, then the \"table\" option also needs to be given as a string",
},
"table": <DataProviderOptionInfo>{
"type": (
AbstractDataProviderType::get(StringType),
AbstractDataProviderType::get(new Type("AbstractTable")),
),
"required": True,
"desc": "the table name or table object; if a table string is provided, then the \"datasource\" "
"option must also be provided",
},
};
const CreateOptions = {
"returning": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(AbstractDataProviderType::anyType),
"desc": "a string (giving the output name) or a hash describing the return parameters for an insert; "
"a hash will have the following keys: 'key': (required) the column name to return, and 'type' "
"(optional) the data type for the output placeholder buffer (ex: 'number')",
},
};
const UpsertOptions = {
"upsert_strategy": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(StringType),
"desc": "providers the upsert strategy; 'UpsertInsertFirst': try to insert first, if it fails, try "
"updating; 'UpsertUpdateFirst': try to update first, if it fails, try inserting; "
"'UpsertSelectFirst': try to select first, if it fails, insert, if it succeeds, update if "
"necessary; 'UpsertInsertOnly': only insert, never update, 'UpsertUpdateOnly': only update, "
"never insert; 'UpsertAuto' (the default) use the most efficient upsert for the underlying DB",
},
"omit_update": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(new Type("softlist<string>")),
"desc": "allows for an asymmetrical upsert where a set of column values is inserted, but a smaller "
"set is updated in case the unique key values are present in the target table; the value of this "
"option should be set to the columns to omit in the update clause",
},
};
const SearchOptions = {
"columns": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(AbstractDataProviderType::anyType),
"desc": "column argument for the select expression",
},
"limit": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(IntType),
"desc": "the maximum number of records to return",
},
"offset": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(IntType),
"desc": "the offset number in records to return",
},
"groupby": <DataProviderOptionInfo>{
"type": new QoreListDataType(new Type("softlist<auto>")),
"desc": "group by argument for the select expression",
},
"having": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(AutoHashType),
"desc": "having argument for the select expression",
},
"orderby": <DataProviderOptionInfo>{
"type": new QoreListDataType(new Type("softlist<string>")),
"desc": "order by argument for the select expression",
},
"forupdate": <DataProviderOptionInfo>{
"type": AbstractDataProviderType::get(SoftBoolType),
"desc": "uses FOR UPDATE with the query to lock records selected",
},
};
const DbUpsertMap = {
AbstractTable::UR_Inserted: UpsertResultInserted,
AbstractTable::UR_Verified: UpsertResultVerified,
AbstractTable::UR_Updated: UpsertResultUpdated,
AbstractTable::UR_Unchanged: UpsertResultUnchanged,
AbstractTable::UR_Deleted: UpsertResultDeleted,
};
protected:
AbstractTable table;
AbstractDatabase db;
Mutex db_lock();
public:
constructor(AbstractTable table);
constructor(*hash<auto> options);
string getName();
*AbstractDataProvider getChildProviders();
bool requiresTransactionManagement();
commit();
rollback();
AbstractDataProviderBulkOperation getBulkInserter();
AbstractDataProviderBulkOperation getBulkUpserter();
*hash<string, hash<MapperRuntimeKeyInfo>> getMapperRuntimeKeys();
protected:
*hash<string, AbstractDataField> getRecordTypeImpl(*hash<auto> search_options);
public:
protected:
*hash<auto> createRecordImpl(hash<auto> rec, *hash<auto> create_options);
public:
string upsertRecordImpl(hash<auto> rec, *hash<auto> upsert_options);
protected:
*hash<auto> searchSingleRecordImpl(hash<auto> where_cond, *hash<auto> search_options);
public:
protected:
AbstractDataProviderBulkRecordInterface searchRecordsBulkImpl(int block_size = 1000, *hash<auto> where_cond, *hash<auto> search_options);
public:
protected:
DbTableRecordIterator searchRecordsImpl(*hash<auto> where_cond, *hash<auto> search_options);
public:
protected:
bool updateSingleRecordImpl(hash<auto> set, hash<auto> where_cond, *hash<auto> search_options);
public:
protected:
int updateRecordsImpl(hash<auto> set, *hash<auto> where_cond, *hash<auto> search_options);
public:
protected:
int deleteRecordsImpl(*hash<auto> where_cond, *hash<auto> search_options);
public:
protected:
hash<DataProviderInfo> getStaticInfoImpl();
public:
int doSequenceKey(string sequence_name);
int doSequenceCurrvalKey(string sequence_name);
};
};
DbDataProvider::DbTableDataProvider::rollback
rollback()
Rolls back data written to the data provider.
DbDataProvider::DbTableDataProvider::getName
string getName()
Returns the data provider name.
DbDataProvider::DbTableDataProvider::doSequenceKey
int doSequenceKey(string sequence_name)
Processes the sequence runtime key in mappers.
DbDataProvider::DbTableDataProvider::getBulkInserter
AbstractDataProviderBulkOperation getBulkInserter()
Returns a bulk insert operation object for the data provider.
DbDataProvider::DbTableDataProvider::SearchOptions
const SearchOptions
Search options.
Definition: DbTableDataProvider.qc.dox.h:126
DbDataProvider::DbTableDataProvider::db
AbstractDatabase db
the database object, if required
Definition: DbTableDataProvider.qc.dox.h:171
True
const True
DbDataProvider::DbTableDataProvider::updateRecordsImpl
int updateRecordsImpl(hash< auto > set, *hash< auto > where_cond, *hash< auto > search_options)
Updates zero or more records matching the search options.
DbDataProvider::DbTableDataProvider::MapperKeyInfo
const MapperKeyInfo
Mapper runtime key info.
Definition: DbTableDataProvider.qc.dox.h:60
DbDataProvider::DbTableDataProvider::requiresTransactionManagement
bool requiresTransactionManagement()
Returns True if the data provider supports transaction management.
DbDataProvider::DbTableDataProvider::CreateOptions
const CreateOptions
Create options.
Definition: DbTableDataProvider.qc.dox.h:98
DbDataProvider::DbTableDataProvider::getChildProviders
*AbstractDataProvider getChildProviders()
Returns child providers; return NOTHING if there are no child providers.
DbDataProvider::DbTableRecordIterator
Defines the record iterator class for Table-based iterators.
Definition: DbTableRecordIterator.qc.dox.h:34
DbDataProvider::DbTableDataProvider::deleteRecordsImpl
int deleteRecordsImpl(*hash< auto > where_cond, *hash< auto > search_options)
Deletes zero or more records.
DbDataProvider::DbTableDataProvider::searchRecordsImpl
DbTableRecordIterator searchRecordsImpl(*hash< auto > where_cond, *hash< auto > search_options)
Returns an iterator for zero or more records matching the search options.
DbDataProvider::DbTableDataProvider::upsertRecordImpl
string upsertRecordImpl(hash< auto > rec, *hash< auto > upsert_options)
Upserts the given record to the data provider.
DbDataProvider::DbTableDataProvider::DbUpsertMap
const DbUpsertMap
Maps SqlUtil Upsert Result Codes to DB Provider Upsert Result Codes.
Definition: DbTableDataProvider.qc.dox.h:158
DbDataProvider::DbTableDataProvider::searchSingleRecordImpl
*hash< auto > searchSingleRecordImpl(hash< auto > where_cond, *hash< auto > search_options)
Returns a single record matching the search options.
DbDataProvider::DbTableDataProvider::UpsertOptions
const UpsertOptions
Upsert options.
Definition: DbTableDataProvider.qc.dox.h:108
DbDataProvider::DbTableDataProvider::updateSingleRecordImpl
bool updateSingleRecordImpl(hash< auto > set, hash< auto > where_cond, *hash< auto > search_options)
Updates a single record matching the search options.
DbDataProvider::DbTableDataProvider::doSequenceCurrvalKey
int doSequenceCurrvalKey(string sequence_name)
Processes the sequence_currval runtime key in mappers.
DbDataProvider::DbTableDataProvider::ConstructorOptions
const ConstructorOptions
Constructor options.
Definition: DbTableDataProvider.qc.dox.h:77
False
const False
DbDataProvider::DbTableDataProvider::getBulkUpserter
AbstractDataProviderBulkOperation getBulkUpserter()
Returns a bulk upsert operation object for the data provider.
DbDataProvider::DbTableDataProvider::constructor
constructor(*hash< auto > options)
Creates the object from constructor options.
DbDataProvider::DbTableDataProvider::getStaticInfoImpl
hash< DataProviderInfo > getStaticInfoImpl()
Returns data provider static info.
DbDataProvider::DbTableDataProvider
Defines a data provider based on a single SQL table.
Definition: DbTableDataProvider.qc.dox.h:34
DbDataProvider::DbTableDataProvider::ProviderInfo
const ProviderInfo
Provider info.
Definition: DbTableDataProvider.qc.dox.h:38
DbDataProvider::DbTableDataProvider::createRecordImpl
*hash< auto > createRecordImpl(hash< auto > rec, *hash< auto > create_options)
Writes the given record to the data provider.
DbDataProvider::DbTableDataProvider::getMapperRuntimeKeys
*hash< string, hash< MapperRuntimeKeyInfo > > getMapperRuntimeKeys()
Returns custom data mapper runtime keys.
DbDataProvider
Qore AbstractDbRecordIterator class definition.
Definition: AbstractDbRecordIterator.qc.dox.h:32
DbDataProvider::DbTableDataProvider::searchRecordsBulkImpl
AbstractDataProviderBulkRecordInterface searchRecordsBulkImpl(int block_size=1000, *hash< auto > where_cond, *hash< auto > search_options)
Returns an iterator for zero or more records matching the search options.
DbDataProvider::DbTableDataProvider::getRecordTypeImpl
*hash< string, AbstractDataField > getRecordTypeImpl(*hash< auto > search_options)
Returns the description of the record type, if any.
DbDataProvider::DbTableDataProvider::table
AbstractTable table
the table
Definition: DbTableDataProvider.qc.dox.h:168
DbDataProvider::DbTableDataProvider::commit
commit()
Commits data written to the data provider.
DbDataProvider::DbTableDataProvider::constructor
constructor(AbstractTable table)
Creates the object.
DbDataProvider::DbTableDataProvider::db_lock
Mutex db_lock()
lock for "db"