Changeset View
Changeset View
Standalone View
Standalone View
src/migration/keximigrate.cpp
Show First 20 Lines • Show All 264 Lines • ▼ Show 20 Line(s) | 264 | { | |||
---|---|---|---|---|---|
265 | QScopedPointer<KDbTableSchema> t(new KDbTableSchema()); | 265 | QScopedPointer<KDbTableSchema> t(new KDbTableSchema()); | ||
266 | KDbEscapedString sqlStatement = KDbEscapedString( | 266 | KDbEscapedString sqlStatement = KDbEscapedString( | ||
267 | "SELECT o_id, o_type, o_name, o_caption, o_desc " | 267 | "SELECT o_id, o_type, o_name, o_caption, o_desc " | ||
268 | "FROM kexi__objects WHERE o_name=%1 AND o_type=%2") | 268 | "FROM kexi__objects WHERE o_name=%1 AND o_type=%2") | ||
269 | .arg(d->sourceConnection->escapeString(tableName)) | 269 | .arg(d->sourceConnection->escapeString(tableName)) | ||
270 | .arg(int(KDb::TableObjectType)); | 270 | .arg(int(KDb::TableObjectType)); | ||
271 | QScopedPointer<KDbRecordData> record; | 271 | QScopedPointer<KDbRecordData> record; | ||
272 | { | 272 | { | ||
273 | QScopedPointer<KDbSqlResult> result(d->sourceConnection->executeSQL(sqlStatement)); | 273 | QSharedPointer<KDbSqlResult> result = d->sourceConnection->prepareSql(sqlStatement); | ||
274 | if (!result) { | 274 | if (!result) { | ||
275 | m_result = d->sourceConnection->result(); | 275 | m_result = d->sourceConnection->result(); | ||
276 | return false; | 276 | return false; | ||
277 | } | 277 | } | ||
278 | record.reset(result->fetchRecordData()); | 278 | record.reset(result->fetchRecordData()); | ||
279 | if (!record) { | 279 | if (!record) { | ||
280 | return !result->lastResult().isError(); | 280 | return !result->lastResult().isError(); | ||
281 | } | 281 | } | ||
282 | if (!destConn->setupObjectData(*record, t.data())) { | 282 | if (!destConn->setupObjectData(*record, t.data())) { | ||
283 | m_result = d->sourceConnection->result(); | 283 | m_result = d->sourceConnection->result(); | ||
284 | return false; | 284 | return false; | ||
285 | } | 285 | } | ||
286 | } | 286 | } | ||
287 | sqlStatement | 287 | sqlStatement | ||
288 | = KDbEscapedString("SELECT t_id, f_type, f_name, f_length, f_precision, f_constraints, " | 288 | = KDbEscapedString("SELECT t_id, f_type, f_name, f_length, f_precision, f_constraints, " | ||
289 | "f_options, f_default, f_order, f_caption, f_help" | 289 | "f_options, f_default, f_order, f_caption, f_help" | ||
290 | " FROM kexi__fields WHERE t_id=%1 ORDER BY f_order").arg(t->id()); | 290 | " FROM kexi__fields WHERE t_id=%1 ORDER BY f_order").arg(t->id()); | ||
291 | QVector<QList<QVariant>> fieldRecords; | 291 | QVector<QList<QVariant>> fieldRecords; | ||
292 | { | 292 | { | ||
293 | QScopedPointer<KDbSqlResult> fieldsResult(d->sourceConnection->executeSQL(sqlStatement)); | 293 | QSharedPointer<KDbSqlResult> fieldsResult = d->sourceConnection->prepareSql(sqlStatement); | ||
294 | if (!fieldsResult) { | 294 | if (!fieldsResult) { | ||
295 | m_result = d->sourceConnection->result(); | 295 | m_result = d->sourceConnection->result(); | ||
296 | return false; | 296 | return false; | ||
297 | } | 297 | } | ||
298 | Q_FOREVER { | 298 | Q_FOREVER { | ||
299 | QScopedPointer<KDbRecordData> fieldsRecord(fieldsResult->fetchRecordData()); | 299 | QScopedPointer<KDbRecordData> fieldsRecord(fieldsResult->fetchRecordData()); | ||
300 | if (!fieldsRecord) { | 300 | if (!fieldsRecord) { | ||
301 | if (!fieldsResult->lastResult().isError()) { | 301 | if (!fieldsResult->lastResult().isError()) { | ||
▲ Show 20 Lines • Show All 521 Lines • ▼ Show 20 Line(s) | |||||
823 | bool KexiMigrate::tableNames(QStringList *tn) | 823 | bool KexiMigrate::tableNames(QStringList *tn) | ||
824 | { | 824 | { | ||
825 | //! @todo Cache list of table names | 825 | //! @todo Cache list of table names | ||
826 | qDebug() << "Reading list of tables..."; | 826 | qDebug() << "Reading list of tables..."; | ||
827 | tn->clear(); | 827 | tn->clear(); | ||
828 | return drv_tableNames(tn); | 828 | return drv_tableNames(tn); | ||
829 | } | 829 | } | ||
830 | 830 | | |||
831 | KDbSqlResult* KexiMigrate::readFromTable(const QString & tableName) | 831 | QSharedPointer<KDbSqlResult> KexiMigrate::readFromTable(const QString & tableName) | ||
832 | { | 832 | { | ||
833 | return drv_readFromTable(tableName); | 833 | return drv_readFromTable(tableName); | ||
834 | } | 834 | } | ||
835 | 835 | | |||
836 | bool KexiMigrate::moveNext() | 836 | bool KexiMigrate::moveNext() | ||
837 | { | 837 | { | ||
838 | return drv_moveNext(); | 838 | return drv_moveNext(); | ||
839 | } | 839 | } | ||
Show All 28 Lines |