Qore DbDataProvider Module Reference 2.1.1
Loading...
Searching...
No Matches
DbDataProvider.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
26namespace DbDataProvider {
28
31class DbDataProvider : public AbstractDataProvider {
32
33public:
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,
48 "has_record": 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,
55 };
56
58
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",
67 "unique_roles": "*",
68 "returns_type": "int",
69 },
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",
74 "unique_roles": "*",
75 "returns_type": "int",
76 },
77 };
78
80 const ConstructorOptions = {
81 "datasource": <DataProviderOptionInfo>{
82 "type": (
83 AbstractDataProviderType::get(StringType),
84 AbstractDataProviderType::get(new Type("AbstractDatasource")),
85 ),
86 "desc": "the datasource connection string or an abstract datasource object",
87 "required": True,
88 },
89 };
90
92 const SearchOptions = {
93 "sql": <DataProviderOptionInfo>{
94 "type": AbstractDataProviderType::get(StringType),
95 "desc": "the raw SQL for the select statement",
96 "required": True,
97 },
98 "args": <DataProviderOptionInfo>{
99 "type": AbstractDataProviderType::get(AutoListType),
100 "desc": "any bind arguments for the select statement",
101 },
102 };
103
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 "
110 "generated",
111 },
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",
115 },
116 "indexes": <DataProviderOptionInfo>{
117 "type": new DbIndexesDataType(),
118 "desc": "a hash of indexes keyed by index name",
119 },
120 "foreign_constraints": <DataProviderOptionInfo>{
121 "type": new DbForeignConstraintsDataType(),
122 "desc": "a hash of foreign constraints keyed by foreign constraint name",
123 },
124 };
125
126protected:
128 AbstractDatabase db;
129
131 static *code datasource_lookup;
132
134 static *code table_lookup;
135
136public:
137
139 constructor(AbstractDatasource ds, *hash<auto> opts);
140
141
143 constructor(AbstractDatabase db);
144
145
147 constructor(*hash<auto> options);
148
149
151 string getName();
152
153
155 *string getDesc();
156
157
159
167
168
170
176
177
179
185
186
188
190 *hash<string, hash<MapperRuntimeKeyInfo>> getMapperRuntimeKeys();
191
192
194 int doSequenceKey(string sequence_name, hash<auto> ctx, *reference<bool> missing_input);
195
196
198 int doSequenceCurrvalKey(string sequence_name, hash<auto> ctx, *reference<bool> missing_input);
199
200
202
207 static *hash<string, AbstractDataField> getRecordTypeFromDescribeHash(hash<auto> describe_hash);
208
210
214protected:
215 *hash<string, AbstractDataField> getRecordTypeImpl(*hash<auto> search_options);
216public:
217
218
220
227protected:
228 AbstractDataProviderBulkRecordInterface searchRecordsBulkImpl(int block_size = 1000, *hash<auto> where_cond, *hash<auto> search_options);
229public:
230
231
233
238protected:
239 AbstractDataProviderRecordIterator searchRecordsImpl(*hash<auto> where_cond, *hash<auto> search_options);
240public:
241
242
244 *list<hash<DataProviderSummaryInfo>> getChildProviderSummaryInfo();
245
246
248
250protected:
252public:
253
254
256
262protected:
263 *AbstractDataProvider getChildProviderImpl(string name);
264public:
265
266
268protected:
269 hash<DataProviderInfo> getStaticInfoImpl();
270public:
271
272
274
282protected:
283 AbstractDataProvider createChildProviderImpl(string name, hash<string, AbstractDataField> fields, *hash<auto> child_create_options);
284public:
285
286
288
295protected:
296 deleteChildProviderImpl(string name, *hash<auto> child_delete_options);
297public:
298
299
301 static setDatasourceLookup(code datasource_lookup);
302
304 static setTableLookup(code table_lookup);
305
307 static AbstractDatasource getDatasource(AbstractDatasource ds);
308
310 static AbstractDatasource getDatasource(string ds_string);
311
313 static AbstractTable getTable(string ds_string, string table_string);
314
316 static AbstractTable getTable(AbstractDatasource ds, string table_string);
317
319 static hash<GenericColumnInfo> getColumnDesc(AbstractDatabase db, AbstractDataField field, *hash<auto> opts);
320
322
324 hash<auto> makeTableDesc(string name, hash<string, AbstractDataField> fields, *hash<auto> opts);
325
326};
327};
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.
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.
*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.
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.
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.
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.
*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
Qore AbstractDbRecordIterator class definition.
Definition: AbstractDbRecordIterator.qc.dox.h:26