10#include "private/qsqldriver_p.h"
11#include "private/qtools_p.h"
134 return d->isOpenError;
392 return identifier.
size() > 2
445 const QSqlRecord &rec,
bool preparedStatement)
const
460 s =
"SELECT "_L1 +
s +
" FROM "_L1 + tableNameString;
465 ?
QString() : tableNameString + u
'.';
469 s.append(
s.isEmpty() ?
"WHERE "_L1 :
" AND "_L1);
470 s.append(tableNamePrefix);
473 s.append(
" IS NULL"_L1);
474 else if (preparedStatement)
482 s =
s +
"UPDATE "_L1 + tableNameString +
" SET "_L1;
487 if (preparedStatement)
493 if (
s.endsWith(
", "_L1))
499 s =
s +
"DELETE FROM "_L1 + tableNameString;
502 s =
s +
"INSERT INTO "_L1 + tableNameString +
" ("_L1;
508 if (preparedStatement)
514 if (vals.isEmpty()) {
518 s[
s.size() - 2] = u
')';
519 s.append(
"VALUES ("_L1).append(vals).append(u
')');
561 const auto nullTxt =
"NULL"_L1;
569 case QMetaType::UInt:
575#if QT_CONFIG(datestring)
576 case QMetaType::QDate:
582 case QMetaType::QTime:
588 case QMetaType::QDateTime:
595 case QMetaType::QString:
596 case QMetaType::QChar:
606 result.replace(u
'\'',
"''"_L1);
610 case QMetaType::Bool:
613 case QMetaType::QByteArray : {
618 for (
const char c :
ba) {
732 d->precisionPolicy = precisionPolicy;
751 return d->precisionPolicy;
804#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)
Sets \l numericalPrecisionPolicy to 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
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
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy
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.
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
Returns true if the field index is null or if there is no field at position index; otherwise returns ...
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
Returns true if the record has a field at position index and this field is to be generated (the defau...
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 reserve(qsizetype size)
Ensures the string has space for at least size characters.
void chop(qsizetype n)
Removes n characters from the end of the string.
QString mid(qsizetype position, qsizetype n=-1) const &
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
void clear()
Clears the contents of the string and makes it null.
qsizetype size() const noexcept
Returns the number of characters in this string.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; 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
QList< QString > QStringList
Constructs a string list that contains the given string, str.
DBusConnection const char DBusError * error
static QString prepareIdentifier(const QString &identifier, QSqlDriver::IdentifierType type, const QSqlDriver *driver)
file open(QIODevice::ReadOnly)
\inmodule QtCore \reentrant