Changeset View
Changeset View
Standalone View
Standalone View
src/KDbCursor.cpp
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 92 | { | |||
---|---|---|---|---|---|
100 | m_fetchResult = FetchInvalid; | 100 | m_fetchResult = FetchInvalid; | ||
101 | 101 | | |||
102 | d->containsRecordIdInfo = (m_query && m_query->masterTable()) | 102 | d->containsRecordIdInfo = (m_query && m_query->masterTable()) | ||
103 | && d->conn->driver()->behavior()->ROW_ID_FIELD_RETURNS_LAST_AUTOINCREMENTED_VALUE == false; | 103 | && d->conn->driver()->behavior()->ROW_ID_FIELD_RETURNS_LAST_AUTOINCREMENTED_VALUE == false; | ||
104 | 104 | | |||
105 | if (m_query) { | 105 | if (m_query) { | ||
106 | //get list of all fields | 106 | //get list of all fields | ||
107 | m_visibleFieldsExpanded = new KDbQueryColumnInfo::Vector(); | 107 | m_visibleFieldsExpanded = new KDbQueryColumnInfo::Vector(); | ||
108 | *m_visibleFieldsExpanded = m_query->visibleFieldsExpanded( | 108 | *m_visibleFieldsExpanded = m_query->visibleFieldsExpanded(conn, | ||
109 | d->containsRecordIdInfo ? KDbQuerySchema::WithInternalFieldsAndRecordId | 109 | d->containsRecordIdInfo ? KDbQuerySchema::FieldsExpandedMode::WithInternalFieldsAndRecordId | ||
110 | : KDbQuerySchema::WithInternalFields); | 110 | : KDbQuerySchema::FieldsExpandedMode::WithInternalFields); | ||
111 | m_logicalFieldCount = m_visibleFieldsExpanded->count() | 111 | m_logicalFieldCount = m_visibleFieldsExpanded->count() | ||
112 | - m_query->internalFields().count() - (d->containsRecordIdInfo ? 1 : 0); | 112 | - m_query->internalFields(conn).count() - (d->containsRecordIdInfo ? 1 : 0); | ||
113 | m_fieldCount = m_visibleFieldsExpanded->count(); | 113 | m_fieldCount = m_visibleFieldsExpanded->count(); | ||
114 | m_fieldsToStoreInRecord = m_fieldCount; | 114 | m_fieldsToStoreInRecord = m_fieldCount; | ||
115 | } else { | 115 | } else { | ||
116 | m_visibleFieldsExpanded = nullptr; | 116 | m_visibleFieldsExpanded = nullptr; | ||
117 | m_logicalFieldCount = 0; | 117 | m_logicalFieldCount = 0; | ||
118 | m_fieldCount = 0; | 118 | m_fieldCount = 0; | ||
119 | m_fieldsToStoreInRecord = 0; | 119 | m_fieldsToStoreInRecord = 0; | ||
120 | } | 120 | } | ||
Show All 19 Lines | 132 | #endif | |||
140 | delete d; | 140 | delete d; | ||
141 | } | 141 | } | ||
142 | 142 | | |||
143 | bool KDbCursor::readAhead() const | 143 | bool KDbCursor::readAhead() const | ||
144 | { | 144 | { | ||
145 | return d->readAhead; | 145 | return d->readAhead; | ||
146 | } | 146 | } | ||
147 | 147 | | |||
148 | KDbConnection* KDbCursor::connection() const | 148 | KDbConnection* KDbCursor::connection() | ||
149 | { | ||||
150 | return d->conn; | ||||
151 | } | ||||
152 | | ||||
153 | const KDbConnection* KDbCursor::connection() const | ||||
149 | { | 154 | { | ||
150 | return d->conn; | 155 | return d->conn; | ||
151 | } | 156 | } | ||
152 | 157 | | |||
153 | KDbQuerySchema *KDbCursor::query() const | 158 | KDbQuerySchema *KDbCursor::query() const | ||
154 | { | 159 | { | ||
155 | return m_query; | 160 | return m_query; | ||
156 | } | 161 | } | ||
▲ Show 20 Lines • Show All 365 Lines • ▼ Show 20 Line(s) | |||||
522 | { | 527 | { | ||
523 | //! @todo doesn't update cursor's buffer YET! | 528 | //! @todo doesn't update cursor's buffer YET! | ||
524 | clearResult(); | 529 | clearResult(); | ||
525 | if (!m_query) | 530 | if (!m_query) | ||
526 | return false; | 531 | return false; | ||
527 | return d->conn->deleteAllRecords(m_query); | 532 | return d->conn->deleteAllRecords(m_query); | ||
528 | } | 533 | } | ||
529 | 534 | | |||
530 | QDebug operator<<(QDebug dbg, const KDbCursor& cursor) | 535 | QDebug debug(QDebug dbg, KDbCursor& cursor, bool buildSql) | ||
531 | { | 536 | { | ||
532 | dbg.nospace() << "CURSOR("; | 537 | dbg.nospace() << "CURSOR("; | ||
533 | if (!cursor.query()) { | 538 | if (!cursor.query()) { | ||
534 | dbg.nospace() << "RAW SQL STATEMENT:" << cursor.rawSql().toString() | 539 | dbg.nospace() << "RAW SQL STATEMENT:" << cursor.rawSql().toString() | ||
535 | << "\n"; | 540 | << "\n"; | ||
536 | } | 541 | } | ||
537 | else { | 542 | else if (buildSql) { | ||
538 | KDbNativeStatementBuilder builder(cursor.connection()); | 543 | KDbNativeStatementBuilder builder(cursor.connection()); | ||
539 | KDbEscapedString sql; | 544 | KDbEscapedString sql; | ||
540 | QString sqlString; | 545 | QString sqlString; | ||
541 | if (builder.generateSelectStatement(&sql, cursor.query())) { | 546 | if (builder.generateSelectStatement(&sql, cursor.query())) { | ||
542 | sqlString = sql.toString(); | 547 | sqlString = sql.toString(); | ||
543 | } | 548 | } | ||
544 | else { | 549 | else { | ||
545 | sqlString = QLatin1String("<CANNOT GENERATE!>"); | 550 | sqlString = QLatin1String("<CANNOT GENERATE!>"); | ||
Show All 11 Lines | |||||
557 | } | 562 | } | ||
558 | else { | 563 | else { | ||
559 | dbg.space() << "NOT_BUFFERED"; | 564 | dbg.space() << "NOT_BUFFERED"; | ||
560 | } | 565 | } | ||
561 | dbg.nospace() << "AT=" << cursor.at() << ")"; | 566 | dbg.nospace() << "AT=" << cursor.at() << ")"; | ||
562 | return dbg.space(); | 567 | return dbg.space(); | ||
563 | } | 568 | } | ||
564 | 569 | | |||
570 | QDebug operator<<(QDebug dbg, KDbCursor &cursor) | ||||
571 | { | ||||
572 | return debug(dbg, cursor, true /*buildSql*/); | ||||
573 | } | ||||
574 | | ||||
575 | QDebug operator<<(QDebug dbg, const KDbCursor &cursor) | ||||
576 | { | ||||
577 | return debug(dbg, const_cast<KDbCursor&>(cursor), false /* !buildSql*/); | ||||
578 | } | ||||
579 | | ||||
565 | void KDbCursor::setOrderByColumnList(const QStringList& columnNames) | 580 | void KDbCursor::setOrderByColumnList(const QStringList& columnNames) | ||
566 | { | 581 | { | ||
567 | Q_UNUSED(columnNames); | 582 | Q_UNUSED(columnNames); | ||
568 | //! @todo implement this: all field names should be found, exit otherwise | 583 | //! @todo implement this: all field names should be found, exit otherwise | ||
569 | 584 | | |||
570 | // OK | 585 | // OK | ||
571 | //! @todo if (!d->orderByColumnList) | 586 | //! @todo if (!d->orderByColumnList) | ||
572 | } | 587 | } | ||
Show All 35 Lines |