8#include <QtSql/qtsqlglobal.h>
9#include <QtCore/qshareddata.h>
10#include <QtCore/qvariant.h>
11#include <QtCore/qstring.h>
17QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(
QSqlFieldPrivate, Q_SQL_EXPORT)
22 Q_PROPERTY(QVariant value READ value WRITE setValue)
23 Q_PROPERTY(QVariant defaultValue READ defaultValue WRITE setDefaultValue)
24 Q_PROPERTY(QString name READ name WRITE setName)
25 Q_PROPERTY(QString tableName READ tableName WRITE setTableName)
26 Q_PROPERTY(QMetaType metaType READ metaType WRITE setMetaType)
27 Q_PROPERTY(RequiredStatus requiredStatus READ requiredStatus WRITE setRequiredStatus)
28 Q_PROPERTY(
bool readOnly READ isReadOnly WRITE setReadOnly)
29 Q_PROPERTY(
bool generated READ isGenerated WRITE setGenerated)
30 Q_PROPERTY(
bool autoValue READ isAutoValue WRITE setAutoValue)
31 Q_PROPERTY(
int length READ length WRITE setLength)
32 Q_PROPERTY(
int precision READ precision WRITE setPrecision)
35 enum RequiredStatus { Unknown = -1, Optional = 0, Required = 1 };
37 explicit QSqlField(
const QString& fieldName = QString(), QMetaType type = QMetaType(),
const QString &tableName = QString());
39 QSqlField(
const QSqlField& other);
40 QSqlField& operator=(
const QSqlField& other);
41 QSqlField(QSqlField &&other)
noexcept =
default;
42 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QSqlField)
45 void swap(QSqlField &other)
noexcept { val.swap(other.val); d.swap(other.d); }
47 bool operator==(
const QSqlField& other)
const;
48 inline bool operator!=(
const QSqlField &other)
const {
return !operator==(other); }
50 void setValue(
const QVariant& value);
51 inline QVariant value()
const
53 void setName(
const QString& name);
55 void setTableName(
const QString &tableName);
56 QString tableName()
const;
58 void setReadOnly(
bool readOnly);
59 bool isReadOnly()
const;
61 bool isAutoValue()
const;
63 QMetaType metaType()
const;
64 void setMetaType(QMetaType type);
66#if QT_DEPRECATED_SINCE(6
, 0
)
68 QT_WARNING_DISABLE_DEPRECATED
69 QT_DEPRECATED_VERSION_X_6_0(
"Use the constructor using a QMetaType instead")
70 QSqlField(
const QString& fieldName, QVariant::Type type,
const QString &tableName = QString())
71 : QSqlField(fieldName, QMetaType(type), tableName)
73 QT_DEPRECATED_VERSION_X_6_0(
"Use metaType() instead")
74 QVariant::Type type()
const {
return QVariant::Type(metaType().id()); }
75 QT_DEPRECATED_VERSION_X_6_0(
"Use setMetaType() instead")
76 void setType(QVariant::Type type) { setMetaType(QMetaType(
int(type))); }
80 void setRequiredStatus(RequiredStatus status);
81 inline void setRequired(
bool required)
82 { setRequiredStatus(required ? Required : Optional); }
83 void setLength(
int fieldLength);
84 void setPrecision(
int precision);
85 void setDefaultValue(
const QVariant &value);
86#if QT_DEPRECATED_SINCE(6
, 8
)
87 QT_DEPRECATED_VERSION_X_6_8(
"This internal value is no longer used.")
88 void setSqlType(
int type);
90 void setGenerated(
bool gen);
91 void setAutoValue(
bool autoVal);
93 RequiredStatus requiredStatus()
const;
95 int precision()
const;
96 QVariant defaultValue()
const;
97#if QT_DEPRECATED_SINCE(6
, 8
)
98 QT_DEPRECATED_VERSION_X_6_8(
"This internal value is no longer used.")
101 bool isGenerated()
const;
102 bool isValid()
const;
108 QExplicitlySharedDataPointer<QSqlFieldPrivate> d;
113#ifndef QT_NO_DEBUG_STREAM
114Q_SQL_EXPORT
QDebug operator<<(QDebug,
const QSqlField &);
void qSplitTableQualifier(const QString &qualifier, QString &catalog, QString &schema, QString &table) const
QList< QVariant * > valueCache
bool fetchLast() override
Positions the result to the last record (last row) in the result.
QVariant handle() const override
Returns the low-level database handle for this result set wrapped in a QVariant or an invalid QVarian...
void detachFromResultSet() override
void virtual_hook(int id, void *data) override
int numRowsAffected() override
Returns the number of rows affected by the last query executed, or -1 if it cannot be determined or i...
bool fetch(int i) override
Positions the result to an arbitrary (zero-based) row index.
bool isNull(int i) override
Returns true if the field at position index in the current row is null; otherwise returns false.
bool exec() override
Executes the query, returning true if successful; otherwise returns false.
bool fetchFirst() override
Positions the result to the first record (row 0) in the result.
int size() override
Returns the size of the SELECT result, or -1 if it cannot be determined or if the query is not a SELE...
bool prepare(const QString &query) override
Prepares the given query for execution; the query will normally use placeholders so that it can be ex...
QSqlRecord record() const override
Returns the current record if the query is active; otherwise returns an empty QSqlRecord.
bool fetchNext() override
Positions the result to the next available record (row) in the result.
bool reset(const QString &query) override
Sets the result to use the SQL statement query for subsequent data retrieval.
bool nextResult() override
QVariant data(int field) override
Returns the data for field index in the current row as a QVariant.
\inmodule QtCore \reentrant
The QSqlError class provides SQL database error information.
The QSqlField class manipulates the fields in SQL database tables and views.
\inmodule QtCore \reentrant
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
static QSqlField qMakeFieldInfo(const QDB2ResultPrivate *d, int i)
static QSqlField qMakeFieldInfo(const SQLHANDLE hStmt)
static bool qMakeStatement(QDB2ResultPrivate *d, bool forwardOnly, bool setForwardOnly=true)
static QByteArray qGetBinaryData(SQLHANDLE hStmt, int column, SQLLEN &lengthIndicator, bool &isNull)
static void qSqlWarning(const QString &message, const T *d)
static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool &isNull)
static SQLBIGINT qGetBigIntData(SQLHANDLE hStmt, int column, bool &isNull)
static int qGetIntData(SQLHANDLE hStmt, int column, bool &isNull)
static SQLTCHAR * qToTChar(const QString &str)
static const SQLSMALLINT TABLENAMESIZE
static const SQLSMALLINT qParamType[4]
static QString qFromTChar(SQLTCHAR *str)
static const int COLNAMESIZE
static QSqlError qMakeError(const QString &err, QSqlError::ErrorType type, const T *p)
static QMetaType qDecodeDB2Type(SQLSMALLINT sqltype)
static QString qDB2Warn(const QDB2DriverPrivate *d, QStringList *errorCodes=nullptr)
static QString qWarnDB2Handle(int handleType, SQLHANDLE handle, int *errorCode)
static QString qDB2Warn(const QDB2ResultPrivate *d, QStringList *errorCodes=nullptr)
static double qGetDoubleData(SQLHANDLE hStmt, int column, bool &isNull)