15#include "private/qsqldriver_p.h"
35 return u -
'a' < 26 || u -
'A' < 26 || u -
'0' < 10 || u ==
'_';
53 if (!closingQuote.isNull()) {
54 if (
ch == closingQuote) {
55 if (closingQuote == u
']'
56 &&
i + 1 <
n &&
query.at(
i + 1) == closingQuote) {
61 closingQuote =
QChar();
69 if (
ch == u
'\'' ||
ch == u
'"' ||
ch == u
'`')
71 else if (!ignoreBraces &&
ch == u
'[')
102 if (!closingQuote.isNull()) {
103 if (
ch == closingQuote) {
104 if (closingQuote == u
']'
105 &&
i + 1 <
n &&
query.at(
i + 1) == closingQuote) {
110 closingQuote =
QChar();
117 && (
i == 0 ||
query.at(
i - 1) != u
':')
125 if (qmarkNotationSupported)
134 if (
ch == u
'\'' ||
ch == u
'"' ||
ch == u
'`')
136 else if (!ignoreBraces &&
ch == u
'[')
357 d->executedQuery =
d->sql;
518 return d->forwardOnly;
548 d->forwardOnly = forward;
571 d->executedQuery =
d->namedToPositionalBinding(
query);
574 d->executedQuery =
d->positionalToNamedBinding(
query);
590 if (
d->holders.isEmpty()) {
592 d->namedToPositionalBinding(
query);
603 case qMetaTypeId<QString>():
605 case qMetaTypeId<QByteArray>():
607 case qMetaTypeId<QDateTime>():
610 case qMetaTypeId<QDate>():
612 case qMetaTypeId<QTime>():
615 case qMetaTypeId<QUuid>():
638 const QString &holder =
d->holders.
at(
i).holderName;
639 const QVariant val =
d->values.
value(
d->indexes.value(holder).value(0,-1));
684 QList<int> &indexes =
d->indexes[
d->fieldSerial(
index)];
685 if (!indexes.contains(
index))
686 indexes.append(
index);
687 if (
d->values.size() <=
index)
688 d->values.resize(
index + 1);
690 if (paramType !=
QSql::In || !
d->types.isEmpty())
691 d->types[
index] = paramType;
705 QSql::ParamType paramType)
711 const QList<int> indexes =
d->indexes.value(placeholder);
712 for (
int idx : indexes) {
713 if (
d->values.size() <= idx)
714 d->values.resize(idx + 1);
715 d->values[idx] =
val;
716 if (paramType !=
QSql::In || !
d->types.isEmpty())
717 d->types[idx] = paramType;
744 return d->values.value(
index);
758 const QList<int> indexes =
d->indexes.value(placeholder);
759 return d->values.value(indexes.value(0,-1));
782 return d->types.value(
d->indexes.value(placeholder).value(0,-1),
QSql::In);
793 return d->values.size();
853 return d->executedQuery;
874 for (
const QHolder &holder : std::as_const(
d->holders))
875 ret.push_back(holder.holderName);
888 return d->holderAt(
index);
900 if (
d->types.isEmpty())
979 const QList<QVariant>
values =
d->values;
1012 return d->precisionPolicy;
1020 d->positionalBindingEnabled =
enable;
1028 return d->positionalBindingEnabled;
\inmodule QtCore\reentrant
\inmodule QtCore \reentrant
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
void append(parameter_type t)
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
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.
DbmsType dbmsType() const
The QSqlError class provides SQL database error information.
The QSqlField class manipulates the fields in SQL database tables and views.
The QSqlRecord class encapsulates a database record.
QString holderAt(int index) const
QString namedToPositionalBinding(const QString &query)
QString positionalToNamedBinding(const QString &query) const
static bool isVariantNull(const QVariant &variant)
QPointer< QSqlDriver > sqldriver
bool positionalBindingEnabled
virtual QString fieldSerial(qsizetype) const
The QSqlResult class provides an abstract interface for accessing data from specific SQL databases.
bool isForwardOnly() const
Returns true if you can only scroll forward through the result set; otherwise returns false.
virtual QVariant lastInsertId() const
Returns the object ID of the most recent inserted row if the database supports it.
QString executedQuery() const
Returns the query that was actually executed.
QSql::ParamType bindValueType(const QString &placeholder) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void clear()
Clears the entire result set and releases any associated resources.
virtual bool execBatch(bool arrayBind=false)
virtual void virtual_hook(int id, void *data)
virtual void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy)
virtual void detachFromResultSet()
bool isPositionalBindingEnabled() const
int at() const
Returns the current (zero-based) row position of the result.
virtual bool prepare(const QString &query)
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
BindingSyntax
This enum type specifies the different syntaxes for specifying placeholders in prepared queries.
QVariant boundValue(const QString &placeholder) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual bool exec()
Executes the query, returning true if successful; otherwise returns false.
void setPositionalBindingEnabled(bool enable)
void addBindValue(const QVariant &val, QSql::ParamType type)
Binds the value val of parameter type paramType to the next available position in the current record ...
virtual ~QSqlResult()
Destroys the object and frees any allocated resources.
bool isSelect() const
Returns true if the current result is from a SELECT statement; otherwise returns false.
virtual void setAt(int at)
This function is provided for derived classes to set the internal (zero-based) row position to index.
virtual void setSelect(bool s)
This function is provided for derived classes to indicate whether or not the current statement is a S...
QString lastQuery() const
Returns the current SQL query text, or an empty string if there isn't one.
bool hasOutValues() const
Returns true if at least one of the query's bound values is a QSql::Out or a QSql::InOut; otherwise r...
virtual void setActive(bool a)
This function is provided for derived classes to set the internal active state to active.
virtual bool fetchPrevious()
Positions the result to the previous record (row) in the result.
virtual bool nextResult()
virtual bool fetch(int i)=0
Positions the result to an arbitrary (zero-based) row index.
QVariantList & boundValues(QT6_DECL_NEW_OVERLOAD)
virtual QVariant handle() const
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
virtual bool fetchNext()
Positions the result to the next available record (row) in the result.
void resetBindCount()
Resets the number of bind parameters.
QSqlResult(const QSqlDriver *db)
Creates a QSqlResult using database driver db.
virtual bool savePrepare(const QString &sqlquery)
Prepares the given query, using the underlying database functionality where possible.
QSqlError lastError() const
Returns the last error associated with the result.
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const
virtual void setLastError(const QSqlError &e)
This function is provided for derived classes to set the last error to error.
virtual QSqlRecord record() const
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
BindingSyntax bindingSyntax() const
Returns the binding syntax used by prepared queries.
int boundValueCount() const
Returns the number of bound values in the result.
virtual void setQuery(const QString &query)
Sets the current query for the result to query.
const QSqlDriver * driver() const
Returns the driver associated with the result.
QString boundValueName(int pos) const
Returns the name of the bound value at position index in the current record (row).
bool isValid() const
Returns true if the result is positioned on a valid record (that is, the result is not positioned bef...
QStringList boundValueNames() const
Returns the names of all bound values.
virtual void setForwardOnly(bool forward)
Sets forward only mode to forward.
virtual void bindValue(int pos, const QVariant &val, QSql::ParamType type)
Binds the value val of parameter type paramType to position index in the current record (row).
bool isActive() const
Returns true if the result has records to be retrieved; otherwise returns false.
QSqlResultPrivate * d_ptr
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype size() const noexcept
Returns the number of characters in this string.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
\inmodule QtCore \reentrant
int typeId() const
Returns the storage type of the value stored in the variant.
bool isNull() const
Returns true if this is a null variant, false otherwise.
QMetaType metaType() const
const void * constData() const
QSet< QString >::iterator it
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
GLenum GLsizei GLsizei GLint * values
[15]
GLenum GLenum GLsizei count
static bool qIsAlnum(QChar ch)
#define QT6_IMPL_NEW_OVERLOAD
selection select(topLeft, bottomRight)