KDbDriver

Search for usage in LXR

#include <KDbDriver.h>

Inheritance diagram for KDbDriver:

Public Types

enum  Features {
  NoFeatures = 0 , SingleTransactions = 1 , MultipleTransactions = 2 , NestedTransactions = 4 ,
  CursorForward = 8 , CursorBackward = (CursorForward + 16) , CompactingDatabaseSupported = 32 , IgnoreTransactions = 1024
}
 

Public Member Functions

 ~KDbDriver () override
 
KDbAdminToolsadminTools () const
 
virtual KDbEscapedString ceilingOrFloorFunctionToString (const QString &name, const KDbNArgExpression &args, KDbQuerySchemaParameterValueListIterator *params, KDb::ExpressionCallStack *callStack) const
 
virtual KDbEscapedString collationSql () const
 
KDbEscapedString concatenateFunctionToString (const KDbBinaryExpression &args, KDbQuerySchemaParameterValueListIterator *params, KDb::ExpressionCallStack *callStack) const
 
const QSet< KDbConnection * > connections () const
 
KDbConnectioncreateConnection (const KDbConnectionData &connData)
 
KDbConnectioncreateConnection (const KDbConnectionData &connData, const KDbConnectionOptions &options)
 
virtual KDB_DEPRECATED KDbEscapedString dateTimeToSql (const QDateTime &v) const
 
virtual KDbEscapedString dateTimeToSql (const QVariant &v) const
 
virtual KDbEscapedString dateToSql (const QVariant &v) const
 
virtual KDbEscapedString escapeBLOB (const QByteArray &array) const =0
 
QByteArray escapeIdentifier (const QByteArray &str) const
 
QString escapeIdentifier (const QString &str) const
 
virtual KDbEscapedString escapeString (const QByteArray &str) const =0
 
virtual KDbEscapedString escapeString (const QString &str) const =0
 
int features () const
 
virtual KDbEscapedString greatestOrLeastFunctionToString (const QString &name, const KDbNArgExpression &args, KDbQuerySchemaParameterValueListIterator *params, KDb::ExpressionCallStack *callStack) const
 
virtual KDbEscapedString hexFunctionToString (const KDbNArgExpression &args, KDbQuerySchemaParameterValueListIterator *params, KDb::ExpressionCallStack *callStack) const
 
virtual KDbEscapedString ifnullFunctionToString (const KDbNArgExpression &args, KDbQuerySchemaParameterValueListIterator *params, KDb::ExpressionCallStack *callStack) const
 
KDbUtils::Property internalProperty (const QByteArray &name) const
 
QList< QByteArrayinternalPropertyNames () const
 
bool isDriverSpecificKeyword (const QByteArray &word) const
 
virtual bool isSystemDatabaseName (const QString &name) const =0
 
bool isSystemFieldName (const QString &name) const
 
virtual bool isSystemObjectName (const QString &name) const =0
 
virtual KDbEscapedString lengthFunctionToString (const KDbNArgExpression &args, KDbQuerySchemaParameterValueListIterator *params, KDb::ExpressionCallStack *callStack) const
 
const KDbDriverMetaDatametaData () const
 
virtual KDbEscapedString randomFunctionToString (const KDbNArgExpression &args, KDbQuerySchemaParameterValueListIterator *params, KDb::ExpressionCallStack *callStack) const
 
virtual QString sqlTypeName (KDbField::Type type, const KDbField &field) const
 
virtual KDbEscapedString timeToSql (const QVariant &v) const
 
bool transactionsSupported () const
 
virtual KDbEscapedString unicodeFunctionToString (const KDbNArgExpression &args, KDbQuerySchemaParameterValueListIterator *params, KDb::ExpressionCallStack *callStack) const
 
KDbEscapedString valueToSql (const KDbField *field, const QVariant &v) const
 
KDbEscapedString valueToSql (const QString &ftype, const QVariant &v) const
 
virtual KDbEscapedString valueToSql (KDbField::Type ftype, const QVariant &v) const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 
- Public Member Functions inherited from KDbResultable
 KDbResultable (const KDbResultable &other)
 
void clearResult ()
 
KDbMessageHandlermessageHandler () const
 
KDbResultableoperator= (const KDbResultable &other)
 
KDbResult result () const
 
virtual QString serverResultName () const
 
void setMessageHandler (KDbMessageHandler *handler)
 
void showMessage ()
 

Static Public Member Functions

static QString defaultSqlTypeName (KDbField::Type type)
 
static bool isKDbSystemObjectName (const QString &name)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Protected Member Functions

 KDbDriver (QObject *parent, const QVariantList &args)
 
virtual KDbEscapedString addLimitTo1 (const KDbEscapedString &sql, bool add=true)
 
KDbDriverBehaviorbehavior ()
 
const KDbDriverBehaviorbehavior () const
 
virtual KDbAdminToolsdrv_createAdminTools () const
 
virtual KDbConnectiondrv_createConnection (const KDbConnectionData &connData, const KDbConnectionOptions &options)=0
 
virtual QByteArray drv_escapeIdentifier (const QByteArray &str) const =0
 
virtual QString drv_escapeIdentifier (const QString &str) const =0
 
virtual bool drv_isSystemFieldName (const QString &name) const =0
 
void initDriverSpecificKeywords (const char *const *keywords)
 
virtual bool isValid ()
 
KDbConnectionremoveConnection (KDbConnection *conn)
 
void setMetaData (const KDbDriverMetaData *metaData)
 
virtual bool supportsDefaultValue (const KDbField &field) const
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Protected Attributes

KDbDriverPrivate *const d
 
- Protected Attributes inherited from KDbResultable
Private *const d
 
KDbResult m_result
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

Database driver's abstraction.

This class is a prototype of the database driver. KDbDriver allows new connections to be created, and groups as their parent. Before destruction, all owned connections are destructed.

Definition at line 49 of file KDbDriver.h.

Member Enumeration Documentation

◆ Features

Features supported by driver (sum of few Features enum items).

Enumerator
SingleTransactions 

single trasactions are only supported

MultipleTransactions 

multiple concurrent trasactions are supported (this implies !SingleTransactions)

NestedTransactions 

nested trasactions are supported (this should imply !SingleTransactions and MultipleTransactions)

CursorForward 

forward moving is supported for cursors (if not available, no cursors available at all)

CursorBackward 

backward moving is supported for cursors (this implies CursorForward)

CompactingDatabaseSupported 

compacting database supported (aka VACUUM)

IgnoreTransactions 

If set, actions related to transactions will be silently bypassed with success. Set this if your driver does not support transactions at all Currently, this is only way to get it working with KDb. Keep in mind that this hack do not provide data integrity! This flag is currently used for MySQL driver.

Definition at line 55 of file KDbDriver.h.

Constructor & Destructor Documentation

◆ ~KDbDriver()

KDbDriver::~KDbDriver ( )
override

Definition at line 64 of file KDbDriver.cpp.

◆ KDbDriver()

KDbDriver::KDbDriver ( QObject * parent,
const QVariantList & args )
protected

Used by KDbDriverManager. Note for driver developers: Reimplement this. In your reimplementation you should initialize:

  • beh->typeNames - to types accepted by your engine
  • beh->features - to combination of selected values from Features enum

You may also want to change options in KDbDriverBehavior *beh member. See drivers/mySQL/mysqldriver.cpp for usage example.

Definition at line 56 of file KDbDriver.cpp.

Member Function Documentation

◆ addLimitTo1()

KDbEscapedString KDbDriver::addLimitTo1 ( const KDbEscapedString & sql,
bool add = true )
protectedvirtual
Returns
SQL statement sql modified by appending a "LIMIT 1" clause, (if possible and if add is true). Used for optimization for the server side. Can be reimplemented for other drivers.

Definition at line 303 of file KDbDriver.cpp.

◆ adminTools()

KDbAdminTools & KDbDriver::adminTools ( ) const
Returns
admin tools object providing a number of database administration tools for the driver. Tools availablility varies from driver to driver. You can check it using features().

Definition at line 118 of file KDbDriver.cpp.

◆ behavior() [1/2]

KDbDriverBehavior * KDbDriver::behavior ( )
protected

Returns structure that provides detailed information about driver's default behavior.

Since
3.1

Definition at line 74 of file KDbDriver.cpp.

◆ behavior() [2/2]

const KDbDriverBehavior * KDbDriver::behavior ( ) const
protected

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 79 of file KDbDriver.cpp.

◆ ceilingOrFloorFunctionToString()

KDbEscapedString KDbDriver::ceilingOrFloorFunctionToString ( const QString & name,
const KDbNArgExpression & args,
KDbQuerySchemaParameterValueListIterator * params,
KDb::ExpressionCallStack * callStack ) const
virtual

Generates native (driver-specific) CEILING() and FLOOR() function calls.

Default implementation USES CEILING() and FLOOR(), respectively. Special case is for SQLite.

Reimplemented in SqliteDriver.

Definition at line 373 of file KDbDriver.cpp.

◆ collationSql()

virtual KDbEscapedString KDbDriver::collationSql ( ) const
inlinevirtual
Returns
SQL clause to add for unicode text collation sequence used in ORDER BY clauses of SQL statements generated by KDb. Later other clauses may use this statement. One space character should be be prepended. Can be reimplemented for other drivers, e.g. the SQLite3 driver returns " COLLATE ''". Default implementation returns empty string.

Reimplemented in SqliteDriver.

Definition at line 232 of file KDbDriver.h.

◆ concatenateFunctionToString()

KDbEscapedString KDbDriver::concatenateFunctionToString ( const KDbBinaryExpression & args,
KDbQuerySchemaParameterValueListIterator * params,
KDb::ExpressionCallStack * callStack ) const

Generates native (driver-specific) function call for concatenation of two strings.

Default implementation USES infix "||" operator. Special case is for MYSQL (CONCAT()).

Todo
API supporting KDbNArgExpression would be useful so instead of a||b||c can be expressed as CONCAT(a,b,c) instead of CONCAT(CONCAT(a,b),c). This requires changes to the KDbSQL parser.

Definition at line 390 of file KDbDriver.cpp.

◆ connections()

const QSet< KDbConnection * > KDbDriver::connections ( ) const
Returns
Set of created connections.

Definition at line 98 of file KDbDriver.cpp.

◆ createConnection() [1/2]

KDbConnection * KDbDriver::createConnection ( const KDbConnectionData & connData)

Definition at line 153 of file KDbDriver.cpp.

◆ createConnection() [2/2]

KDbDriver::createConnection ( const KDbConnectionData & connData,
const KDbConnectionOptions & options )

Creates connection using connData as parameters.

Returns
nullptr and sets error message on error. driverId member of connData will be updated with the driver's ID. options can be set for the new connection.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Todo
needed? connData->setDriverId(id());

Definition at line 139 of file KDbDriver.cpp.

◆ dateTimeToSql() [1/2]

KDbEscapedString KDbDriver::dateTimeToSql ( const QDateTime & v) const
virtual

Converts date/time value to string.

Default implementation uses dateTimeToSql(QVariant). Deprecated, use dateTimeToSql(QVariant).

Not compatible with all drivers - reimplement.

Definition at line 267 of file KDbDriver.cpp.

◆ dateTimeToSql() [2/2]

KDbEscapedString KDbDriver::dateTimeToSql ( const QVariant & v) const
virtual

Converts date/time value to string.

Default implementation uses KDb::dateTimeToIsoString().

Not compatible with all drivers - reimplement.

Since
3.2.0

Definition at line 262 of file KDbDriver.cpp.

◆ dateToSql()

KDbEscapedString KDbDriver::dateToSql ( const QVariant & v) const
virtual

Converts date value to string.

Default implementation uses KDb::dateToSql().

Not compatible with all drivers - reimplement.

Since
3.2.0

Definition at line 252 of file KDbDriver.cpp.

◆ defaultSqlTypeName()

QString KDbDriver::defaultSqlTypeName ( KDbField::Type type)
static

used when we do not have KDbDriver instance yet

Definition at line 166 of file KDbDriver.cpp.

◆ drv_createAdminTools()

KDbAdminTools * KDbDriver::drv_createAdminTools ( ) const
protectedvirtual

Creates admin tools object providing a number of database administration tools for the driver. This is called once per driver.

Note for driver developers: Reimplement this method by returning a KDbAdminTools-derived object. Default implementation creates anmd returns an empty admin tools KDbAdminTools object.

See also
adminTools()

Reimplemented in SqliteDriver.

Definition at line 125 of file KDbDriver.cpp.

◆ drv_createConnection()

virtual KDbConnection * KDbDriver::drv_createConnection ( const KDbConnectionData & connData,
const KDbConnectionOptions & options )
protectedpure virtual

For reimplementation: creates and returns connection object with additional structures specific for a given driver. KDbConnection object should inherit KDbConnection and have a destructor that descructs all allocated driver-dependent connection structures.

Implemented in SybaseDriver, MysqlDriver, PostgresqlDriver, and SqliteDriver.

◆ drv_escapeIdentifier() [1/2]

virtual QByteArray KDbDriver::drv_escapeIdentifier ( const QByteArray & str) const
protectedpure virtual

This is overloaded version of drv_escapeIdentifier( const QString& str ) to be implemented in the same way.

Implemented in SybaseDriver, MysqlDriver, PostgresqlDriver, and SqliteDriver.

◆ drv_escapeIdentifier() [2/2]

virtual QString KDbDriver::drv_escapeIdentifier ( const QString & str) const
protectedpure virtual

Driver-specific SQL string escaping. This method is used by escapeIdentifier(). Implement escaping for any character like " or ' as your database engine requires. Do not append or prepend any quotation marks characters - it is automatically done by escapeIdentifier() using KDbDriverBehavior::OPENING_QUOTATION_MARK_BEGIN_FOR_IDENTIFIER and KDbDriverBehavior::CLOSING_QUOTATION_MARK_BEGIN_FOR_IDENTIFIER.

Implemented in SybaseDriver, MysqlDriver, PostgresqlDriver, and SqliteDriver.

◆ drv_isSystemFieldName()

virtual bool KDbDriver::drv_isSystemFieldName ( const QString & name) const
protectedpure virtual
Returns
true if name is a system field's name, build-in system field that cannot be used or created by a user, and in most cases user even shouldn't see this. The list is specific for a given driver implementation. For implementation.

Implemented in SybaseDriver, SqliteDriver, MysqlDriver, and PostgresqlDriver.

◆ escapeBLOB()

virtual KDbEscapedString KDbDriver::escapeBLOB ( const QByteArray & array) const
pure virtual

Driver-specific SQL BLOB value escaping. Implement escaping for any character like " or ' and \0 as your database engine requires. Prepend and append quotation marks.

Implemented in SybaseDriver, MysqlDriver, PostgresqlDriver, and SqliteDriver.

◆ escapeIdentifier() [1/2]

QByteArray KDbDriver::escapeIdentifier ( const QByteArray & str) const

Definition at line 279 of file KDbDriver.cpp.

◆ escapeIdentifier() [2/2]

QString KDbDriver::escapeIdentifier ( const QString & str) const
Returns
str string with applied driver-specific identifier escaping

This escaping can be used for field, table, database names, etc.

See also
KDb::escapeIdentifier

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 272 of file KDbDriver.cpp.

◆ escapeString() [1/2]

virtual KDbEscapedString KDbDriver::escapeString ( const QByteArray & str) const
pure virtual

This is overloaded version of escapeString( const QString& str ) to be implemented in the same way.

Implemented in SybaseDriver, MysqlDriver, PostgresqlDriver, and SqliteDriver.

◆ escapeString() [2/2]

virtual KDbEscapedString KDbDriver::escapeString ( const QString & str) const
pure virtual

Driver-specific SQL string escaping. Implement escaping for any character like " or ' as your database engine requires. Prepend and append quotation marks.

Implemented in SybaseDriver, MysqlDriver, PostgresqlDriver, and SqliteDriver.

◆ features()

int KDbDriver::features ( ) const
Returns
driver's features that are combination of KDbDriver::Features enum.
Todo
change int to Features

Definition at line 108 of file KDbDriver.cpp.

◆ greatestOrLeastFunctionToString()

KDbEscapedString KDbDriver::greatestOrLeastFunctionToString ( const QString & name,
const KDbNArgExpression & args,
KDbQuerySchemaParameterValueListIterator * params,
KDb::ExpressionCallStack * callStack ) const
virtual

Generates native (driver-specific) GREATEST() and LEAST() function calls.

Default implementation just uses GREATEST() and LEAST(), respectively. (this works only with MySQL >= 5.0.13). For backends workarounds are added.

Reimplemented in MysqlDriver, PostgresqlDriver, and SqliteDriver.

Definition at line 343 of file KDbDriver.cpp.

◆ hexFunctionToString()

KDbEscapedString KDbDriver::hexFunctionToString ( const KDbNArgExpression & args,
KDbQuerySchemaParameterValueListIterator * params,
KDb::ExpressionCallStack * callStack ) const
virtual

Generates native (driver-specific) HEX() function call.

Default implementation uses HEX(val).

Reimplemented in PostgresqlDriver.

Definition at line 319 of file KDbDriver.cpp.

◆ ifnullFunctionToString()

KDbEscapedString KDbDriver::ifnullFunctionToString ( const KDbNArgExpression & args,
KDbQuerySchemaParameterValueListIterator * params,
KDb::ExpressionCallStack * callStack ) const
virtual

Generates native (driver-specific) IFNULL() function call.

Default implementation uses IFNULL().

Reimplemented in PostgresqlDriver.

Definition at line 327 of file KDbDriver.cpp.

◆ initDriverSpecificKeywords()

void KDbDriver::initDriverSpecificKeywords ( const char *const * keywords)
protected

Used to initialise the dictionary of driver-specific keywords. Should be called by the driver's constructor. keywords should be 0-terminated array of null-terminated strings.

Definition at line 298 of file KDbDriver.cpp.

◆ internalProperty()

KDbUtils::Property KDbDriver::internalProperty ( const QByteArray & name) const
Returns
internal property with a name name for this driver. If there's no such property defined for driver, a null property is returned.

Definition at line 286 of file KDbDriver.cpp.

◆ internalPropertyNames()

QList< QByteArray > KDbDriver::internalPropertyNames ( ) const
Returns
a list of internal property names for this driver.

Definition at line 291 of file KDbDriver.cpp.

◆ isDriverSpecificKeyword()

bool KDbDriver::isDriverSpecificKeyword ( const QByteArray & word) const
Returns
true if word is a driver-specific keyword.
See also
KDb::isKDbSqlKeyword(const QByteArray&)

Definition at line 308 of file KDbDriver.cpp.

◆ isKDbSystemObjectName()

bool KDbDriver::isKDbSystemObjectName ( const QString & name)
static
Returns
true if name is a related to KDb's 'system' object's name, i.e. when name starts with "kexi__" prefix.
See also
isSystemDatabaseName() isSystemObjectName() isSystemFieldName()

Definition at line 173 of file KDbDriver.cpp.

◆ isSystemDatabaseName()

virtual bool KDbDriver::isSystemDatabaseName ( const QString & name) const
pure virtual
Returns
true if name is a database type-specific system database's name, e.g. name of a built-in system database that cannot be created by a user, and in most cases user a name that user shouldn't even see.
See also
isKDbSystemObjectName() isSystemObjectName() isSystemFieldName()

Implemented in SqliteDriver, SybaseDriver, MysqlDriver, and PostgresqlDriver.

◆ isSystemFieldName()

bool KDbDriver::isSystemFieldName ( const QString & name) const
Returns
true if name is a system field's name, build-in system field that cannot be used or created by a user, and in most cases user even shouldn't see this. The list is specific for a given driver implementation.
See also
isSystemDatabaseName() isKDbSystemObjectName() isSystemObjectName()

Definition at line 180 of file KDbDriver.cpp.

◆ isSystemObjectName()

virtual bool KDbDriver::isSystemObjectName ( const QString & name) const
pure virtual
Returns
true if n is a database type-specific system object's name, e.g. name of a built-in system table that cannot be created by the user, and in most cases a name that user shouldn't even see.
See also
isSystemDatabaseName() isKDbSystemObjectName() isSystemFieldName()

Implemented in SqliteDriver, MysqlDriver, and PostgresqlDriver.

◆ isValid()

bool KDbDriver::isValid ( )
protectedvirtual
Returns
true if this driver's implementation is valid. Just a few constraints are checked to ensure that driver developer didn't forget something. This method is called automatically on createConnection(), and proper error message is set properly on error. Drivers can reimpement this method but should call KDbDriver::isValid() first.

Definition at line 84 of file KDbDriver.cpp.

◆ lengthFunctionToString()

KDbEscapedString KDbDriver::lengthFunctionToString ( const KDbNArgExpression & args,
KDbQuerySchemaParameterValueListIterator * params,
KDb::ExpressionCallStack * callStack ) const
virtual

Generates native (driver-specific) LENGTH() function call.

Default implementation uses LENGTH().

Reimplemented in MysqlDriver, and PostgresqlDriver.

Definition at line 335 of file KDbDriver.cpp.

◆ metaData()

const KDbDriverMetaData * KDbDriver::metaData ( ) const

Info about the driver.

Definition at line 103 of file KDbDriver.cpp.

◆ randomFunctionToString()

KDbEscapedString KDbDriver::randomFunctionToString ( const KDbNArgExpression & args,
KDbQuerySchemaParameterValueListIterator * params,
KDb::ExpressionCallStack * callStack ) const
virtual

Generates native (driver-specific) RANDOM() and RANDOM(X,Y) function calls.

Accepted args can contain zero or two positive integer arguments X, Y; X < Y. In case of numeric arguments, RANDOM(X, Y) returns a random integer that is equal or greater than X and less than Y. Default implementation for RANDOM() returns F() where F is behavior()->RANDOM_FUNCTION. This works with PostgreSQL. Default implementation for RANDOM(X,Y) returns (X + FLOOR(F()*(Y-X+1))) where F is behavior()->RANDOM_FUNCTION. This works with PostgreSQL. If args has neither zero nor two arguments, empty string is returned.

Reimplemented in SqliteDriver.

Definition at line 352 of file KDbDriver.cpp.

◆ removeConnection()

KDbConnection * KDbDriver::removeConnection ( KDbConnection * conn)
protected
Returns
connection conn, does not delete it nor affect. Returns nullptr if conn is not owned by this driver. After this, you are owner of conn object, so you should eventually delete it. Better use KDbConnection destructor.

Definition at line 158 of file KDbDriver.cpp.

◆ setMetaData()

void KDbDriver::setMetaData ( const KDbDriverMetaData * metaData)
protected

Used by the driver manager to set metaData for just loaded driver.

Definition at line 313 of file KDbDriver.cpp.

◆ sqlTypeName()

QString KDbDriver::sqlTypeName ( KDbField::Type type,
const KDbField & field ) const
virtual

SQL-implementation-dependent name of given type

Reimplemented in MysqlDriver, and PostgresqlDriver.

Definition at line 130 of file KDbDriver.cpp.

◆ supportsDefaultValue()

virtual bool KDbDriver::supportsDefaultValue ( const KDbField & field) const
inlineprotectedvirtual
Returns
true if the database supports specifying default values for field field. true by default. For example MySQL does not support default values for BLOB, TEXT, GEOMETRY, and JSON types. (https://dev.mysql.com/doc/refman/5.7/en/data-type-defaults.html).

Reimplemented in MysqlDriver.

Definition at line 407 of file KDbDriver.h.

◆ timeToSql()

KDbEscapedString KDbDriver::timeToSql ( const QVariant & v) const
virtual

Converts time value to string.

Default implementation uses KDb::timeToIsoString().

Not compatible with all drivers - reimplement.

Since
3.2.0

Definition at line 257 of file KDbDriver.cpp.

◆ transactionsSupported()

bool KDbDriver::transactionsSupported ( ) const
Returns
true if transaction are supported (single or multiple).

Definition at line 113 of file KDbDriver.cpp.

◆ unicodeFunctionToString()

KDbEscapedString KDbDriver::unicodeFunctionToString ( const KDbNArgExpression & args,
KDbQuerySchemaParameterValueListIterator * params,
KDb::ExpressionCallStack * callStack ) const
virtual

Generates native (driver-specific) UNICODE() function call.

Default implementation USES UNICODE(). Special case is for MYSQL and PostgreSQL.

Reimplemented in MysqlDriver, and PostgresqlDriver.

Definition at line 382 of file KDbDriver.cpp.

◆ valueToSql() [1/3]

KDbEscapedString KDbDriver::valueToSql ( const KDbField * field,
const QVariant & v ) const
inline

Like above method, for field.

Definition at line 162 of file KDbDriver.h.

◆ valueToSql() [2/3]

KDbEscapedString KDbDriver::valueToSql ( const QString & ftype,
const QVariant & v ) const
inline

Like above but with the fildtype as string.

Definition at line 157 of file KDbDriver.h.

◆ valueToSql() [3/3]

KDbEscapedString KDbDriver::valueToSql ( KDbField::Type ftype,
const QVariant & v ) const
virtual

Escapes and converts value v (for type ftype) to string representation required by SQL commands. Reimplement this if you need other behavior (eg. for 'date' type handling) This implementation return date, datetime and time values in ISO format, what seems to be accepted by SQL servers.

See also
Qt::DateFormat
Note
it was compatible with SQLite: https://www.sqlite.org/lang_datefunc.html

Definition at line 246 of file KDbDriver.cpp.

Member Data Documentation

◆ d

KDbDriverPrivate* const KDbDriver::d
protected

Definition at line 426 of file KDbDriver.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:50:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.