10#include "private/qsqldriver_p.h"
11#include "private/qtools_p.h"
134 return d->isOpenError;
392 return identifier.
size() > 2
446 const QSqlRecord &rec,
bool preparedStatement)
const
461 s =
"SELECT "_L1 +
s +
" FROM "_L1 + tableNameString;
466 ?
QString() : tableNameString + u
'.';
470 s.append(
s.isEmpty() ?
"WHERE "_L1 :
" AND "_L1);
471 s.append(tableNamePrefix);
474 s.append(
" IS NULL"_L1);
475 else if (preparedStatement)
483 s =
s +
"UPDATE "_L1 + tableNameString +
" SET "_L1;
488 if (preparedStatement)
494 if (
s.endsWith(
", "_L1))
500 s =
s +
"DELETE FROM "_L1 + tableNameString;
503 s =
s +
"INSERT INTO "_L1 + tableNameString +
" ("_L1;
509 if (preparedStatement)
519 s[
s.size() - 2] = u
')';
520 s.append(
"VALUES ("_L1).append(vals).append(u
')');
562 const auto nullTxt =
"NULL"_L1;
570 case QMetaType::UInt:
576#if QT_CONFIG(datestring)
577 case QMetaType::QDate:
583 case QMetaType::QTime:
589 case QMetaType::QDateTime:
596 case QMetaType::QString:
597 case QMetaType::QChar:
607 result.replace(u
'\'',
"''"_L1);
611 case QMetaType::Bool:
614 case QMetaType::QByteArray : {
619 for (
const char c :
ba) {
745 d->precisionPolicy = precisionPolicy;
759 return d->precisionPolicy;
812#include "moc_qsqldriver.cpp"
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
void reserve(qsizetype size)
Attempts to allocate memory for at least size bytes.
bool isValid() const
Returns true if this datetime represents a definite moment, otherwise false.
constexpr bool isValid() const
Returns true if this date is valid; otherwise returns false.
The QSqlDriver class is an abstract base class for accessing specific SQL databases.
virtual QString formatValue(const QSqlField &field, bool trimStrings=false) const
Returns a string representation of the field value for the database.
virtual bool commitTransaction()
This function is called to commit a transaction.
IdentifierType
This enum contains a list of SQL identifier types.
virtual bool cancelQuery()
QSqlDriver(QObject *parent=nullptr)
Constructs a new driver with the given parent.
StatementType
This enum contains a list of SQL statement (or clause) types the driver can create.
void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy)
virtual bool unsubscribeFromNotification(const QString &name)
This function is called to unsubscribe from event notifications from the database.
virtual QSqlIndex primaryIndex(const QString &tableName) const
Returns the primary index for table tableName.
virtual QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
virtual bool beginTransaction()
This function is called to begin a transaction.
QSqlError lastError() const
Returns a QSqlError object which contains information about the last error that occurred on the datab...
virtual QString sqlStatement(StatementType type, const QString &tableName, const QSqlRecord &rec, bool preparedStatement) const
Returns a SQL statement of type type for the table tableName with the values from rec.
virtual QSqlRecord record(const QString &tableName) const
Returns a QSqlRecord populated with the names of the fields in table tableName.
virtual bool rollbackTransaction()
This function is called to rollback a transaction.
virtual QString escapeIdentifier(const QString &identifier, IdentifierType type) const
Returns the identifier escaped according to the database rules.
bool isOpenError() const
Returns true if the there was an error opening the database connection; otherwise returns false.
DbmsType dbmsType() const
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
virtual void setLastError(const QSqlError &e)
This function is used to set the value of the last error, error, that occurred on the database.
virtual QVariant handle() const
Returns the low-level database handle wrapped in a QVariant or an invalid variant if there is no hand...
virtual bool open(const QString &db, const QString &user=QString(), const QString &password=QString(), const QString &host=QString(), int port=-1, const QString &connOpts=QString())=0
Derived classes must reimplement this pure virtual function to open a database connection on database...
virtual bool isOpen() const
Returns true if the database connection is open; otherwise returns false.
virtual int maximumIdentifierLength(IdentifierType type) const
virtual void setOpenError(bool e)
This function sets the open error state of the database to error.
virtual bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
virtual bool hasFeature(DriverFeature f) const =0
Returns true if the driver supports feature feature; otherwise returns false.
virtual bool subscribeToNotification(const QString &name)
This function is called to subscribe to event notifications from the database.
virtual void setOpen(bool o)
This function sets the open state of the database to open.
~QSqlDriver()
Destroys the object and frees any allocated resources.
virtual QStringList tables(QSql::TableType tableType) const
Returns a list of the names of the tables in the database.
virtual QStringList subscribedToNotifications() const
Returns a list of the names of the event notifications that are currently subscribed to.
The QSqlError class provides SQL database error information.
The QSqlField class manipulates the fields in SQL database tables and views.
QMetaType metaType() const
Returns the field's type as stored in the database.
QVariant value() const
Returns the value of the field as a QVariant.
bool isNull() const
Returns true if the field's value is NULL; otherwise returns false.
The QSqlIndex class provides functions to manipulate and describe database indexes.
The QSqlRecord class encapsulates a database record.
bool isNull(int i) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QSqlField field(int i) const
Returns the field at position index.
int count() const
Returns the number of fields in the record.
bool isGenerated(int i) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString fieldName(int i) const
Returns the name of the field at position index.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
void chop(qsizetype n)
Removes n characters from the end of the string.
void clear()
Clears the contents of the string and makes it null.
qsizetype size() const
Returns the number of characters in this string.
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & append(QChar c)
bool isValid() const
Returns true if the time is valid; otherwise returns false.
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has userType() \l QMetaType::QDateTime,...
QTime toTime() const
Returns the variant as a QTime if the variant has userType() \l QMetaType::QTime, \l QMetaType::QDate...
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
QDate toDate() const
Returns the variant as a QDate if the variant has userType() \l QMetaType::QDate, \l QMetaType::QDate...
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has userType() \l QMetaType::QByteArray or \l QMet...
list append(new Employee("Blackpool", "Stephen"))
Combined button and popup list for selecting options.
constexpr char toHexLower(char32_t value) noexcept
DBusConnection const char DBusError * error
static QString prepareIdentifier(const QString &identifier, QSqlDriver::IdentifierType type, const QSqlDriver *driver)
file open(QIODevice::ReadOnly)
\inmodule QtCore \reentrant
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent