Loading...
Searching...
No Matches
DbTableDataProvider.qc.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
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,
"supports_add_field": True,
"supports_update_field": True,
"supports_delete_field": True,
"supports_search_expressions": True,
"constructor_options": ConstructorOptions,
"search_options": SearchOptions,
"create_options": CreateOptions,
"upsert_options": UpsertOptions,
"expressions": (AbstractDataProvider::GenericExpressions - DP_SEARCH_OP_REGEX) + {
OP_LIKE: <DataProviderExpressionInfo>{
"type": DET_Operator,
"name": "like",
"label": OP_LIKE,
"symbol": "like",
"desc": "The SQL 'like' operator",
"args": (DataProviderSignatureStringType, DataProviderSignatureStringValueType),
"return_type": AbstractDataProviderTypeMap."bool",
},
},
"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, *LoggerInterface logger) ;
constructor(*hash<auto> options);
string getName();
*string getDesc();
hash<DataProviderInfo> getInfo();
*AbstractDataProvider getChildProviders();
bool requiresTransactionManagement();
beginTransaction();
commit();
rollback();
AbstractDataProviderBulkOperation getBulkInserter();
AbstractDataProviderBulkOperation getBulkUpserter();
*hash<string, hash<MapperRuntimeKeyInfo>> getMapperRuntimeKeys();
int doSequenceKey(string sequence_name, hash<auto> ctx, *reference<bool> missing_input);
int doSequenceCurrvalKey(string sequence_name, hash<auto> ctx, *reference<bool> missing_input);
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:
protected:
addFieldImpl(AbstractDataField field, *hash<auto> field_add_options);
public:
protected:
updateFieldImpl(string name, AbstractDataField field, *hash<auto> field_update_options);
public:
protected:
deleteFieldImpl(string name, *hash<auto> field_delete_options);
public:
protected:
alignTable(hash<auto> table_desc);
public:
protected:
execDdlSql(list<auto> sqll);
public:
};
};
DbDataProvider::DbTableDataProvider
Defines a data provider based on a single SQL table.
Definition: DbTableDataProvider.qc.dox.h:28
DbDataProvider::DbTableDataProvider::doSequenceCurrvalKey
int doSequenceCurrvalKey(string sequence_name, hash< auto > ctx, *reference< bool > missing_input)
Processes the sequence_currval runtime key in mappers as a mapper key handler.
DbDataProvider::DbTableDataProvider::execDdlSql
execDdlSql(list< auto > sqll)
Executes the given DDL SQL string list.
DbDataProvider::DbTableDataProvider::doSequenceKey
int doSequenceKey(string sequence_name, hash< auto > ctx, *reference< bool > missing_input)
Processes the sequence runtime key in mappers as a mapper key handler.
DbDataProvider::DbTableDataProvider::addFieldImpl
addFieldImpl(AbstractDataField field, *hash< auto > field_add_options)
Creates a new field.
DbDataProvider::DbTableDataProvider::getDesc
*string getDesc()
Returns the data provider description.
DbDataProvider::DbTableDataProvider::getName
string getName()
Returns the data provider name.
DbDataProvider::DbTableDataProvider::getChildProviders
*AbstractDataProvider getChildProviders()
Returns child providers; return NOTHING if there are no child providers.
DbDataProvider::DbTableDataProvider::beginTransaction
beginTransaction()
Begins a transaction in the datasource underlying the table.
DbDataProvider::DbTableDataProvider::db_lock
Mutex db_lock()
lock for "db"
DbDataProvider::DbTableDataProvider::MapperKeyInfo
const MapperKeyInfo
Mapper runtime key info; see details below.
Definition: DbTableDataProvider.qc.dox.h:74
DbDataProvider::DbTableDataProvider::DbUpsertMap
const DbUpsertMap
Maps SqlUtil Upsert Result Codes to DB Provider Upsert Result Codes.
Definition: DbTableDataProvider.qc.dox.h:211
DbDataProvider::DbTableDataProvider::commit
commit()
Commits data written to the data provider.
DbDataProvider::DbTableDataProvider::ProviderInfo
const ProviderInfo
Provider info.
Definition: DbTableDataProvider.qc.dox.h:32
DbDataProvider::DbTableDataProvider::getStaticInfoImpl
hash< DataProviderInfo > getStaticInfoImpl()
Returns data provider static info.
DbDataProvider::DbTableDataProvider::upsertRecordImpl
string upsertRecordImpl(hash< auto > rec, *hash< auto > upsert_options)
Upserts the given record to the data provider.
DbDataProvider::DbTableDataProvider::ConstructorOptions
const ConstructorOptions
Constructor options.
Definition: DbTableDataProvider.qc.dox.h:91
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::SearchOptions
const SearchOptions
Search options; see details below.
Definition: DbTableDataProvider.qc.dox.h:179
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::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::constructor
constructor(AbstractTable table, *LoggerInterface logger)
Creates the object.
DbDataProvider::DbTableDataProvider::alignTable
alignTable(hash< auto > table_desc)
Align table with the given description.
DbDataProvider::DbTableDataProvider::CreateOptions
const CreateOptions
Create options; see details below.
Definition: DbTableDataProvider.qc.dox.h:121
DbDataProvider::DbTableDataProvider::createRecordImpl
*hash< auto > createRecordImpl(hash< auto > rec, *hash< auto > create_options)
Writes the given record to the data provider.
DbDataProvider::DbTableDataProvider::getRecordTypeImpl
*hash< string, AbstractDataField > getRecordTypeImpl(*hash< auto > search_options)
Returns the description of the record type, if any.
DbDataProvider::DbTableDataProvider::getInfo
hash< DataProviderInfo > getInfo()
Returns data provider info.
DbDataProvider::DbTableDataProvider::searchSingleRecordImpl
*hash< auto > searchSingleRecordImpl(hash< auto > where_cond, *hash< auto > search_options)
Returns a single record matching the search options.
DbDataProvider::DbTableDataProvider::db
AbstractDatabase db
the database object, if required
Definition: DbTableDataProvider.qc.dox.h:224
DbDataProvider::DbTableDataProvider::getBulkUpserter
AbstractDataProviderBulkOperation getBulkUpserter()
Returns a bulk upsert operation object for the data provider.
DbDataProvider::DbTableDataProvider::deleteRecordsImpl
int deleteRecordsImpl(*hash< auto > where_cond, *hash< auto > search_options)
Deletes zero or more records.
DbDataProvider::DbTableDataProvider::table
AbstractTable table
the table
Definition: DbTableDataProvider.qc.dox.h:221
DbDataProvider::DbTableDataProvider::updateFieldImpl
updateFieldImpl(string name, AbstractDataField field, *hash< auto > field_update_options)
Updates an existing field.
DbDataProvider::DbTableDataProvider::getMapperRuntimeKeys
*hash< string, hash< MapperRuntimeKeyInfo > > getMapperRuntimeKeys()
Returns custom data mapper runtime keys.
DbDataProvider::DbTableDataProvider::constructor
constructor(*hash< auto > options)
Creates the object from constructor options.
DbDataProvider::DbTableDataProvider::UpsertOptions
const UpsertOptions
Upsert options; see details below.
Definition: DbTableDataProvider.qc.dox.h:138
DbDataProvider::DbTableDataProvider::rollback
rollback()
Rolls back data written to the data provider.
DbDataProvider::DbTableDataProvider::deleteFieldImpl
deleteFieldImpl(string name, *hash< auto > field_delete_options)
Deletes an existing field.
DbDataProvider::DbTableDataProvider::requiresTransactionManagement
bool requiresTransactionManagement()
Returns True if the data provider supports transaction management.
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::getBulkInserter
AbstractDataProviderBulkOperation getBulkInserter()
Returns a bulk insert operation object for the data provider.
DbDataProvider::DbTableRecordIterator
Defines the record iterator class for Table-based iterators.
Definition: DbTableRecordIterator.qc.dox.h:28
DbDataProvider
Qore AbstractDbRecordIterator class definition.
Definition: AbstractDbRecordIterator.qc.dox.h:26