Commit 2a5b4891 authored by Jarosław Staniek's avatar Jarosław Staniek
Browse files

Simplify algorithm of QuerySchema::addTable

Unnecessary checks were performed since alias is empty. Also display
debug instead of warning because the case handled is nothing unusual.
parent 3b76ea46
......@@ -991,19 +991,14 @@ void QuerySchema::addTable(TableSchema *table, const QByteArray& alias)
if (!table)
return;
//only append table if:
//-it has alias
//-it has no alias but there is no such table on the list
// only append table if: it has alias or it has no alias but there is no such table on the list
if (alias.isEmpty() && d->tables.contains(table)) {
const QString tableNameLower(table->name().toLower());
const QString aliasLower(alias.toLower());
int num = -1;
foreach(TableSchema *table, d->tables) {
foreach(TableSchema *t, d->tables) {
num++;
if (table->name().toLower() == tableNameLower) {
const QString& tAlias = tableAlias(num);
if (tAlias == aliasLower) {
KexiDBWarn << "table with" << tAlias << "alias already added!";
if (0 == t->name().compare(table->name(), Qt::CaseInsensitive)) {
if (tableAlias(num).isEmpty()) {
KexiDBDbg << "table" << table->name() << "without alias already added";
return;
}
}
......
......@@ -408,8 +408,8 @@ public:
TableSchema::List* tables() const;
/*! Adds \a table schema as one of tables used in a query.
if \a alias is not empty, it will be assigned to this table
using setTableAlias(position, alias)
If \a alias is not empty, it will be assigned to this table
using setTableAlias(position, alias).
*/
void addTable(TableSchema *table, const QByteArray& alias = QByteArray());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment