35 const ProviderInfo = <DataProviderInfo>{
36 "type":
"DbDataProvider",
37 "supports_read": True,
38 "supports_bulk_read": True,
39 "supports_children": True,
40 "constructor_options": ConstructorOptions,
41 "search_options": SearchOptions,
42 "create_options": NOTHING,
43 "upsert_options": NOTHING,
44 "child_create_options": ChildCreateOptions,
45 "supports_search_expressions": True,
46 "expressions": AbstractDataProvider::GenericExpressions,
47 "transaction_management": True,
49 "record_requires_search_options": True,
50 "supports_child_create": True,
51 "supports_child_delete": True,
52 "children_can_support_apis": False,
53 "children_can_support_records": True,
54 "children_can_support_transactions": True,
63 const MapperKeyInfo = Mapper::MapperKeyInfo + {
64 "sequence": <MapperRuntimeKeyInfo>{
65 "desc":
"names the DB sequence that will be used to populate the field",
66 "value_type":
"string",
68 "returns_type":
"int",
70 "sequence_currval": <MapperRuntimeKeyInfo>{
71 "desc":
"names the DB sequence that will be used to populate the field; the current value of the "
72 "sequence is used; will not increment the sequence",
73 "value_type":
"string",
75 "returns_type":
"int",
80 const ConstructorOptions = {
81 "datasource": <DataProviderOptionInfo>{
83 AbstractDataProviderType::get(StringType),
84 AbstractDataProviderType::get(
new Type(
"AbstractDatasource")),
86 "desc":
"the datasource connection string or an abstract datasource object",
92 const SearchOptions = {
93 "sql": <DataProviderOptionInfo>{
94 "type": AbstractDataProviderType::get(StringType),
95 "desc":
"the raw SQL for the select statement",
98 "args": <DataProviderOptionInfo>{
99 "type": AbstractDataProviderType::get(AutoListType),
100 "desc":
"any bind arguments for the select statement",
105 const ChildCreateOptions = {
106 "primary_key": <DataProviderOptionInfo>{
107 "type": AbstractDataProviderType::get(
"softlist<string>"),
108 "desc":
"a list of column names for the primary key for the table; use `primary_key_name` to set the "
109 "name of the primary key constraint manually, otherwise a suitable name will be automatically "
112 "primary_key_name": <DataProviderOptionInfo>{
113 "type": AbstractDataProviderType::get(StringType),
114 "desc":
"the name of the primary key constraint; only used if `primary_key` is set",
116 "indexes": <DataProviderOptionInfo>{
118 "desc":
"a hash of indexes keyed by index name",
120 "foreign_constraints": <DataProviderOptionInfo>{
122 "desc":
"a hash of foreign constraints keyed by foreign constraint name",
194 int doSequenceKey(
string sequence_name, hash<auto> ctx, *reference<bool> missing_input);
228 *hash<auto> where_cond, *hash<auto> search_options) {
239 AbstractDataProviderRecordIterator
searchRecordsImpl(*hash<auto> where_cond, *hash<auto> search_options);
283 *hash<auto> child_create_options) {
284 hash<auto> table_desc = makeTableDesc(name, fields, child_create_options);
285 AbstractTable table = db.makeTable(name, table_desc);
286 DbTableTransactionHelper th(table);
319 static AbstractTable
getTable(
string ds_string,
string table_string);
322 static AbstractTable
getTable(AbstractDatasource ds,
string table_string);
325 static hash<GenericColumnInfo>
getColumnDesc(AbstractDatabase db, AbstractDataField field, *hash<auto> opts);
330 hash<auto>
makeTableDesc(
string name, hash<string, AbstractDataField> fields, *hash<auto> opts);
static *code datasource_lookup
Lookup to get an abstract datasource from a name.
Definition: DbDataProvider.qc.dox.h:131
static AbstractTable getTable(string ds_string, string table_string)
Returns an AbstractTable object from the given datasource and table strings.
beginTransaction()
Begins a transaction in the datasource.
commit()
Commits any transaction in progress in the datasource.
static *hash< string, AbstractDataField > getRecordTypeFromDescribeHash(hash< auto > describe_hash)
Returns the record type description from a describe hash.
*string getDesc()
Returns the data provider description.
*hash< string, hash< MapperRuntimeKeyInfo > > getMapperRuntimeKeys()
Returns custom data mapper runtime keys.
AbstractDataProviderRecordIterator searchRecordsImpl(*hash< auto > where_cond, *hash< auto > search_options)
Returns an iterator for zero or more records matching the search options.
AbstractDatabase db
The database object.
Definition: DbDataProvider.qc.dox.h:128
static AbstractTable getTable(AbstractDatasource ds, string table_string)
Returns an AbstractTable object from the given datasource and table arguments.
private AbstractDataProvider createChildProviderImpl(string name, hash< string, AbstractDataField > fields, *hash< auto > child_create_options)
Creates a new child data provider and returns it after adding as a child.
Definition: DbDataProvider.qc.dox.h:282
int doSequenceKey(string sequence_name, hash< auto > ctx, *reference< bool > missing_input)
Processes the sequence runtime key in mappers as a mapper key handler.
static hash< GenericColumnInfo > getColumnDesc(AbstractDatabase db, AbstractDataField field, *hash< auto > opts)
Returns a column description hash for a field.
static setDatasourceLookup(code datasource_lookup)
Sets the datasource lookup.
static AbstractDatasource getDatasource(AbstractDatasource ds)
Returns the given AbstractDatasource object.
deleteChildProviderImpl(string name, *hash< auto > child_delete_options)
Deletes a child data provider.
*AbstractDataProvider getChildProviderImpl(string name)
Returns the given child provider or NOTHING if the given child is unknown.
private 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.
Definition: DbDataProvider.qc.dox.h:227
constructor(AbstractDatasource ds, *hash< auto > opts)
creates the object
*list< string > getChildProviderNamesImpl()
Returns a list of child data provider names, if any.
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.
hash< auto > makeTableDesc(string name, hash< string, AbstractDataField > fields, *hash< auto > opts)
Returns a table description hash from a field description.
static AbstractDatasource getDatasource(string ds_string)
Returns an AbstractDatasource object from the given string.
string getName()
Returns the data provider name.
static *code table_lookup
Lookup to get an abstract table from a datasource and a name.
Definition: DbDataProvider.qc.dox.h:134
constructor(AbstractDatabase db)
creates the object
*hash< string, AbstractDataField > getRecordTypeImpl(*hash< auto > search_options)
Returns the description of the record type, if any.
static setTableLookup(code table_lookup)
Sets the table lookup.
hash< DataProviderInfo > getStaticInfoImpl()
Returns data provider static info.
*list< hash< DataProviderSummaryInfo > > getChildProviderSummaryInfo()
Return data provider summary info.
constructor(*hash< auto > options)
Creates the object from constructor options.
rollback()
Rolls back any transaction in progress in the datasource.
The type definition for foreign constraints.
Definition: DbForeignConstraintsDataType.qc.dox.h:28
The type definition for DB indexes.
Definition: DbIndexesDataType.qc.dox.h:28
Defines the record iterator class for Table-based iterators.
Definition: DbSelectBulkRecordInterface.qc.dox.h:28
Defines a data provider based on a single SQL table.
Definition: DbTableDataProvider.qc.dox.h:28
Qore AbstractDbRecordIterator class definition.
Definition: AbstractDbRecordIterator.qc.dox.h:26