diff options
| author | 2016-06-13 18:42:42 -0400 | |
|---|---|---|
| committer | 2016-06-13 18:42:42 -0400 | |
| commit | 5d9314f134ddd3dc4c853e398ac90ba247fb2e4f (patch) | |
| tree | 5c457fc188036988d7abd29a3eb09931e406510f /SQLiteStudio3/coreSQLiteStudio/impl | |
| parent | 8e640722c62692818ab840d50b3758f89a41a54e (diff) | |
Imported Upstream version 3.1.0upstream/3.1.0
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/impl')
| -rw-r--r-- | SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.cpp | 19 | ||||
| -rw-r--r-- | SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.h | 2 |
2 files changed, 17 insertions, 4 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.cpp b/SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.cpp index 75d94eb..7d9c1ba 100644 --- a/SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.cpp @@ -69,7 +69,7 @@ TokenList DbAttacherImpl::getDbTokens() void DbAttacherImpl::detachAttached() { - foreach (const QString& dbName, dbNameToAttach.leftValues()) + for (const QString& dbName : dbNameToAttach.leftValues()) db->detach(nameToDbMap[dbName]); dbNameToAttach.clear(); @@ -87,7 +87,7 @@ QHash<QString, TokenList> DbAttacherImpl::groupDbTokens(const TokenList& dbToken // Filter out tokens of unknown databases and group results by name QHash<QString,TokenList> groupedDbTokens; QString strippedName; - foreach (TokenPtr token, dbTokens) + for (TokenPtr token : dbTokens) { strippedName = stripObjName(token->value, dialect); if (!nameToDbMap.contains(strippedName, Qt::CaseInsensitive)) @@ -101,8 +101,14 @@ QHash<QString, TokenList> DbAttacherImpl::groupDbTokens(const TokenList& dbToken bool DbAttacherImpl::attachAllDbs(const QHash<QString, TokenList>& groupedDbTokens) { QString attachName; - foreach (const QString& dbName, groupedDbTokens.keys()) + for (const QString& dbName : groupedDbTokens.keys()) { + if (dbName.toLower() == "main") + { + mainDbNameUsed = true; + continue; + } + attachName = db->attach(nameToDbMap[dbName]); if (attachName.isNull()) { @@ -121,7 +127,7 @@ QHash<TokenPtr, TokenPtr> DbAttacherImpl::getTokenMapping(const TokenList& dbTok QHash<TokenPtr, TokenPtr> tokenMapping; QString strippedName; TokenPtr dstToken; - foreach (TokenPtr srcToken, dbTokens) + for (TokenPtr srcToken : dbTokens) { strippedName = stripObjName(srcToken->value, dialect); if (strippedName.compare("main", Qt::CaseInsensitive) == 0 || @@ -158,6 +164,11 @@ void DbAttacherImpl::replaceTokensInQueries(const QHash<TokenPtr, TokenPtr>& tok } } +bool DbAttacherImpl::getMainDbNameUsed() const +{ + return mainDbNameUsed; +} + BiStrHash DbAttacherImpl::getDbNameToAttach() const { return dbNameToAttach; diff --git a/SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.h b/SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.h index 49307c6..6fbe6c8 100644 --- a/SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.h +++ b/SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.h @@ -18,6 +18,7 @@ class DbAttacherImpl : public DbAttacher void detachDatabases(); BiStrHash getDbNameToAttach() const; QString getQuery() const; + bool getMainDbNameUsed() const; private: /** @@ -83,6 +84,7 @@ class DbAttacherImpl : public DbAttacher Dialect dialect; BiStrHash dbNameToAttach; StrHash<Db*> nameToDbMap; + bool mainDbNameUsed = false; }; class DbAttacherDefaultFactory : public DbAttacherFactory |
