summaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.cpp
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2016-06-13 18:42:42 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2016-06-13 18:42:42 -0400
commit5d9314f134ddd3dc4c853e398ac90ba247fb2e4f (patch)
tree5c457fc188036988d7abd29a3eb09931e406510f /SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.cpp
parent8e640722c62692818ab840d50b3758f89a41a54e (diff)
Imported Upstream version 3.1.0upstream/3.1.0
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.cpp')
-rw-r--r--SQLiteStudio3/coreSQLiteStudio/impl/dbattacherimpl.cpp19
1 files changed, 15 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;