Changeset View
Changeset View
Standalone View
Standalone View
src/parser/KDbParser_p.cpp
Show First 20 Lines • Show All 414 Lines • ▼ Show 20 Line(s) | 407 | // kdbDebug() << "addTable: " << tname; | |||
---|---|---|---|---|---|
415 | 415 | | |||
416 | //-------add fields | 416 | //-------add fields | ||
417 | if (!colViews.isEmpty()) { | 417 | if (!colViews.isEmpty()) { | ||
418 | columnNum = 0; | 418 | columnNum = 0; | ||
419 | bool containsAsteriskColumn = false; // used to check duplicated asterisks (disallowed) | 419 | bool containsAsteriskColumn = false; // used to check duplicated asterisks (disallowed) | ||
420 | for (int i = 0; i < colViews.argCount(); i++, columnNum++) { | 420 | for (int i = 0; i < colViews.argCount(); i++, columnNum++) { | ||
421 | const KDbExpression e(colViews.arg(i)); | 421 | const KDbExpression e(colViews.arg(i)); | ||
422 | KDbExpression columnExpr(e); | 422 | KDbExpression columnExpr(e); | ||
423 | columnExpr = columnExpr.resolveQuotedIdentifiers(&parseInfo); | ||||
423 | KDbVariableExpression aliasVariable; | 424 | KDbVariableExpression aliasVariable; | ||
424 | if (e.expressionClass() == KDb::SpecialBinaryExpression && e.isBinary() | 425 | if (e.expressionClass() == KDb::SpecialBinaryExpression && e.isBinary() | ||
425 | && (e.token() == KDbToken::AS || e.token() == KDbToken::AS_EMPTY)) { | 426 | && (e.token() == KDbToken::AS || e.token() == KDbToken::AS_EMPTY)) { | ||
426 | //KDb::SpecialBinaryExpression: with alias | 427 | //KDb::SpecialBinaryExpression: with alias | ||
427 | columnExpr = e.toBinary().left(); | 428 | columnExpr = e.toBinary().left(); | ||
428 | aliasVariable = e.toBinary().right().toVariable(); | 429 | aliasVariable = e.toBinary().right().toVariable(); | ||
429 | if (aliasVariable.isNull()) { | 430 | if (aliasVariable.isNull()) { | ||
430 | setError(KDbParser::tr("Invalid alias definition for column \"%1\".") | 431 | setError(KDbParser::tr("Invalid alias definition for column \"%1\".") | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 494 | if (!globalParser->error().message().isEmpty()) { // we could not return earlier (inside the loop) | |||
494 | // because we want run CLEANUP what could crash QMutableListIterator. | 495 | // because we want run CLEANUP what could crash QMutableListIterator. | ||
495 | return nullptr; | 496 | return nullptr; | ||
496 | } | 497 | } | ||
497 | } | 498 | } | ||
498 | //----- SELECT options | 499 | //----- SELECT options | ||
499 | if (options) { | 500 | if (options) { | ||
500 | //----- WHERE expr. | 501 | //----- WHERE expr. | ||
501 | if (!options->whereExpr.isNull()) { | 502 | if (!options->whereExpr.isNull()) { | ||
502 | if (!options->whereExpr.validate(&parseInfo)) { | 503 | KDbExpression whereExpr = options->whereExpr.resolveQuotedIdentifiers(&parseInfo); | ||
504 | if (!whereExpr.validate(&parseInfo)) { | ||||
503 | setError(parseInfo.errorMessage(), parseInfo.errorDescription()); | 505 | setError(parseInfo.errorMessage(), parseInfo.errorDescription()); | ||
504 | return nullptr; | 506 | return nullptr; | ||
505 | } | 507 | } | ||
506 | KDbQuerySchemaPrivate::setWhereExpressionInternal(querySchema, options->whereExpr); | 508 | KDbQuerySchemaPrivate::setWhereExpressionInternal(querySchema, whereExpr); | ||
507 | } | 509 | } | ||
508 | //----- ORDER BY | 510 | //----- ORDER BY | ||
509 | if (options->orderByColumns) { | 511 | if (options->orderByColumns) { | ||
510 | KDbOrderByColumnList *orderByColumnList = querySchema->orderByColumnList(); | 512 | KDbOrderByColumnList *orderByColumnList = querySchema->orderByColumnList(); | ||
511 | int count = options->orderByColumns->count(); | 513 | int count = options->orderByColumns->count(); | ||
512 | QList<OrderByColumnInternal>::ConstIterator it(options->orderByColumns->constEnd()); | 514 | QList<OrderByColumnInternal>::ConstIterator it(options->orderByColumns->constEnd()); | ||
513 | --it; | 515 | --it; | ||
514 | for (;count > 0; --it, --count) | 516 | for (;count > 0; --it, --count) | ||
Show All 38 Lines |