32 const ProviderInfo = <DataProviderInfo>{
33 "type":
"DbDataProvider",
34 "supports_read": True,
35 "supports_bulk_read": True,
36 "supports_children": True,
37 "constructor_options": ConstructorOptions,
38 "search_options": SearchOptions,
39 "create_options": NOTHING,
40 "upsert_options": NOTHING,
41 "child_create_options": ChildCreateOptions,
42 "transaction_management": True,
44 "record_requires_search_options": True,
45 "supports_child_create": True,
46 "supports_child_delete": True,
47 "children_can_support_apis": False,
48 "children_can_support_records": True,
49 "children_can_support_transactions": True,
53 const ConstructorOptions = {
54 "datasource": <DataProviderOptionInfo>{
56 AbstractDataProviderType::get(StringType),
57 AbstractDataProviderType::get(
new Type(
"AbstractDatasource")),
59 "desc":
"the datasource connection string or an abstract datasource object",
65 const SearchOptions = {
66 "sql": <DataProviderOptionInfo>{
67 "type": AbstractDataProviderType::get(StringType),
68 "desc":
"the raw SQL for the select statement",
71 "args": <DataProviderOptionInfo>{
72 "type": AbstractDataProviderType::get(AutoListType),
73 "desc":
"any bind arguments for the select statement",
78 const ChildCreateOptions = {
79 "primary_key": <DataProviderOptionInfo>{
80 "type": AbstractDataProviderType::get(
"softlist<string>"),
81 "desc":
"a list of column names for the primary key for the table; use `primary_key_name` to set the "
82 "name of the primary key constraint manually, otherwise a suitable name will be automatically "
85 "primary_key_name": <DataProviderOptionInfo>{
86 "type": AbstractDataProviderType::get(StringType),
87 "desc":
"the name of the primary key constraint; only used if `primary_key` is set",
89 "indexes": <DataProviderOptionInfo>{
91 "desc":
"a hash of indexes keyed by index name",
93 "foreign_constraints": <DataProviderOptionInfo>{
95 "desc":
"a hash of foreign constraints keyed by foreign constraint name",
187 *hash<auto> where_cond, *hash<auto> search_options) {
198 AbstractDataProviderRecordIterator
searchRecordsImpl(*hash<auto> where_cond, *hash<auto> search_options);
242 *hash<auto> child_create_options) {
243 hash<auto> table_desc = makeTableDesc(name, fields, child_create_options);
244 AbstractTable table = db.makeTable(name, table_desc);
245 DbTableTransactionHelper th(table);
278 static AbstractTable
getTable(
string ds_string,
string table_string);
281 static AbstractTable
getTable(AbstractDatasource ds,
string table_string);
284 static hash<GenericColumnInfo>
getColumnDesc(AbstractDatabase db, AbstractDataField field, *hash<auto> opts);
289 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:104
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.
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:101
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:241
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:186
constructor(AbstractDatasource ds, *hash< auto > opts)
creates the object
*list< string > getChildProviderNamesImpl()
Returns a list of child data provider names, if any.
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:107
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:4
The type definition for DB indexes.
Definition: DbIndexesDataType.qc.dox.h:4
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