Changeset View
Changeset View
Standalone View
Standalone View
src/KDb.h
Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | |||||
116 | of last inserted record for result @a result. | 116 | of last inserted record for result @a result. | ||
117 | 117 | | |||
118 | Simply, method internally fetches values of the last inserted record and returns selected | 118 | Simply, method internally fetches values of the last inserted record and returns selected | ||
119 | field's value. The field belong to @a tableName table. | 119 | field's value. The field belong to @a tableName table. | ||
120 | Requirements: the field must be of integer type, there must be a record inserted using query | 120 | Requirements: the field must be of integer type, there must be a record inserted using query | ||
121 | for which the @a result is returned. | 121 | for which the @a result is returned. | ||
122 | On error std::numeric_limits<quint64>::max() is returned. | 122 | On error std::numeric_limits<quint64>::max() is returned. | ||
123 | Last inserted record is identified by a magical record identifier, usually called ROWID | 123 | Last inserted record is identified by a magical record identifier, usually called ROWID | ||
124 | (PostgreSQL has it as well as SQLite; see KDbDriverBehavior::ROW_ID_FIELD_RETURNS_LAST_AUTOINCREMENTED_VALUE). | 124 | (PostgreSQL has it as well as SQLite; see | ||
125 | KDbDriverBehavior::ROW_ID_FIELD_RETURNS_LAST_AUTOINCREMENTED_VALUE). | ||||
125 | ROWID's value will be assigned back to @a recordId if this pointer is not null. | 126 | ROWID's value will be assigned back to @a recordId if this pointer is not null. | ||
126 | */ | 127 | */ | ||
127 | KDB_EXPORT quint64 lastInsertedAutoIncValue(KDbSqlResult *result, | 128 | KDB_EXPORT quint64 lastInsertedAutoIncValue(QSharedPointer<KDbSqlResult> *result, | ||
128 | const QString& autoIncrementFieldName, const QString& tableName, quint64* recordId = nullptr); | 129 | const QString &autoIncrementFieldName, | ||
130 | const QString &tableName, quint64 *recordId = nullptr); | ||||
anthonyfieroni: Shared pointer make sense when it's passed by value to increase ref count. | |||||
staniek: Thanks Anthony, definitely that was too mechanical change.
| |||||
Done, the param is now optional. Feel free to review the other code :) staniek: Done, the param is now optional. Feel free to review the other code :) | |||||
129 | 131 | | |||
130 | /*! @overload int lastInsertedAutoIncValue(KDbSqlResult *, const QString&, const QString&, quint64*) | 132 | /** | ||
133 | * @overload | ||||
134 | * | ||||
131 | * Accepts @a recordId that can be obtained from KDbPreparedStatement::lastInsertRecordId() | 135 | * Accepts @a recordId that can be obtained from KDbPreparedStatement::lastInsertRecordId() | ||
132 | * or KDbSqlResult::lastInsertRecordId(). | 136 | * or KDbSqlResult::lastInsertRecordId(). | ||
133 | */ | 137 | */ | ||
134 | KDB_EXPORT quint64 lastInsertedAutoIncValue(KDbConnection *conn, const quint64 recordId, | 138 | KDB_EXPORT quint64 lastInsertedAutoIncValue(KDbConnection *conn, const quint64 recordId, | ||
135 | const QString& autoIncrementFieldName, const QString& tableName); | 139 | const QString &autoIncrementFieldName, | ||
140 | const QString &tableName); | ||||
136 | 141 | | |||
137 | /*! @overload int lastInsertedAutoIncValue(KDbSqlResult *, const QString&, const QString&, quint64*) | 142 | /** | ||
143 | @overload | ||||
138 | */ | 144 | */ | ||
139 | inline quint64 lastInsertedAutoIncValue(KDbSqlResult *result, | 145 | inline quint64 lastInsertedAutoIncValue(QSharedPointer<KDbSqlResult> *result, | ||
140 | const QString& autoIncrementFieldName, const KDbTableSchema& table, quint64* recordId = nullptr) | 146 | const QString &autoIncrementFieldName, | ||
147 | const KDbTableSchema &table, quint64 *recordId = nullptr) | ||||
141 | { | 148 | { | ||
142 | return lastInsertedAutoIncValue(result, autoIncrementFieldName, table.name(), recordId); | 149 | return lastInsertedAutoIncValue(result, autoIncrementFieldName, table.name(), recordId); | ||
143 | } | 150 | } | ||
144 | 151 | | |||
145 | /*! @return list of field types for field type group @a typeGroup. */ | 152 | /*! @return list of field types for field type group @a typeGroup. */ | ||
146 | KDB_EXPORT const QList<KDbField::Type> fieldTypesForGroup(KDbField::TypeGroup typeGroup); | 153 | KDB_EXPORT const QList<KDbField::Type> fieldTypesForGroup(KDbField::TypeGroup typeGroup); | ||
147 | 154 | | |||
148 | /*! @return list of translated field type names for field type group @a typeGroup. */ | 155 | /*! @return list of translated field type names for field type group @a typeGroup. */ | ||
▲ Show 20 Lines • Show All 584 Lines • Show Last 20 Lines |
Shared pointer make sense when it's passed by value to increase ref count.