diff --git a/DatabaseManager/DatabaseManager.Core/DatabaseManager.Core.csproj b/DatabaseManager/DatabaseManager.Core/DatabaseManager.Core.csproj index ac53ce4d..8191d064 100644 --- a/DatabaseManager/DatabaseManager.Core/DatabaseManager.Core.csproj +++ b/DatabaseManager/DatabaseManager.Core/DatabaseManager.Core.csproj @@ -5,11 +5,11 @@ https://github.com/victor-wiki/DatabaseManager Database manage tool for: SqlServer, MySql, Oracle and Postgres. victor-wiki - 2.0.22 - detect sql query type: handle quoted keyword + 2.0.23 + bug fix: script translate not use details mode to fetch definition AnyCPU;x64 - 2.0.22 - 2.0.22 + 2.0.23 + 2.0.23 diff --git a/DatabaseManager/DatabaseManager.Core/Manager/TranslateManager.cs b/DatabaseManager/DatabaseManager.Core/Manager/TranslateManager.cs index cb7f08ff..42d08ad4 100644 --- a/DatabaseManager/DatabaseManager.Core/Manager/TranslateManager.cs +++ b/DatabaseManager/DatabaseManager.Core/Manager/TranslateManager.cs @@ -17,13 +17,13 @@ public class TranslateManager public async Task Translate(DatabaseType sourceDbType, DatabaseType targetDbType, DatabaseObject dbObject, ConnectionInfo connectionInfo, bool removeCarriagRreturnChar = false) { - DbInterpreterOption sourceScriptOption = new DbInterpreterOption() { ScriptOutputMode = GenerateScriptOutputMode.None }; + DbInterpreterOption sourceScriptOption = new DbInterpreterOption() { ScriptOutputMode = GenerateScriptOutputMode.None, ObjectFetchMode = DatabaseObjectFetchMode.Details }; DbInterpreterOption targetScriptOption = new DbInterpreterOption() { ScriptOutputMode = GenerateScriptOutputMode.WriteToString }; - DbConveterInfo script = new DbConveterInfo() { DbInterpreter = DbInterpreterHelper.GetDbInterpreter(sourceDbType, connectionInfo, sourceScriptOption) }; - DbConveterInfo target = new DbConveterInfo() { DbInterpreter = DbInterpreterHelper.GetDbInterpreter(targetDbType, new ConnectionInfo(), sourceScriptOption) }; + DbConveterInfo source = new DbConveterInfo() { DbInterpreter = DbInterpreterHelper.GetDbInterpreter(sourceDbType, connectionInfo, sourceScriptOption) }; + DbConveterInfo target = new DbConveterInfo() { DbInterpreter = DbInterpreterHelper.GetDbInterpreter(targetDbType, new ConnectionInfo(), targetScriptOption) }; - using (DbConverter dbConverter = new DbConverter(script, target)) + using (DbConverter dbConverter = new DbConverter(source, target)) { var option = dbConverter.Option; diff --git a/DatabaseManager/DatabaseManager.CoreApp/Controls/UC_QueryEditor.cs b/DatabaseManager/DatabaseManager.CoreApp/Controls/UC_QueryEditor.cs index b08c03cf..70b849d6 100644 --- a/DatabaseManager/DatabaseManager.CoreApp/Controls/UC_QueryEditor.cs +++ b/DatabaseManager/DatabaseManager.CoreApp/Controls/UC_QueryEditor.cs @@ -83,7 +83,7 @@ private void tsmiCopy_Click(object sender, EventArgs e) private void CopyText() { - Clipboard.SetDataObject(this.txtEditor.SelectedText); + Clipboard.SetDataObject(this.txtEditor.SelectedText); } private void tsmiPaste_Click(object sender, EventArgs e) @@ -120,7 +120,7 @@ private void txtEditor_KeyDown(object sender, KeyEventArgs e) { this.ShowFindBox(); } - else if(e.Control && e.KeyCode == Keys.C) + else if (e.Control && e.KeyCode == Keys.C) { this.CopyText(); } @@ -278,6 +278,11 @@ private void HandleKeyUpForIntellisense(KeyEventArgs e) { if (this.enableIntellisense) { + if (token.Type == SqlWordTokenType.String) + { + return; + } + SqlWord word = this.FindWord(token.Text); if (word.Type == SqlWordTokenType.Table) @@ -319,11 +324,28 @@ private void HandleKeyUpForIntellisense(KeyEventArgs e) { if (this.enableIntellisense) { - this.ShowWordListByToken(token); + if (!this.IsWordInQuotationChar(token)) + { + this.ShowWordListByToken(token); + } } } } + private bool IsWordInQuotationChar(SqlWordToken token) + { + int startIndex = token.StopIndex; + + if (startIndex == 0) + { + return false; + } + + int singleQotationCharCount = this.txtEditor.Text.Substring(0, startIndex).Count(item => item == '\''); + + return singleQotationCharCount % 2 != 0; + } + private void HighlightingWord(SqlWordToken token) { int start = this.txtEditor.SelectionStart; @@ -554,7 +576,7 @@ private SqlWordToken GetLastWordToken(bool noAction = false, bool isInsert = fal int i = -1; - bool exited = false; + bool existed = false; for (i = index; i >= 0; i--) { char c = this.txtEditor.Text[i]; @@ -580,7 +602,7 @@ private SqlWordToken GetLastWordToken(bool noAction = false, bool isInsert = fal } else { - exited = true; + existed = true; break; } } @@ -596,7 +618,7 @@ private SqlWordToken GetLastWordToken(bool noAction = false, bool isInsert = fal token.Text = word; - token.StartIndex = i + (exited ? 1 : 0); + token.StartIndex = i + (existed ? 1 : 0); if (token.StartIndex == token.StopIndex && isInsert && word.Length > 0) { @@ -612,9 +634,11 @@ private SqlWordToken GetLastWordToken(bool noAction = false, bool isInsert = fal if (isQuotationPaired && word.StartsWith("'")) { List afterChars = new List(); + for (int j = currentIndex; j < this.txtEditor.Text.Length; j++) { char c = this.txtEditor.Text[j]; + if (Regex.IsMatch(c.ToString(), delimeterPattern)) { break; @@ -644,7 +668,11 @@ private SqlWordToken GetLastWordToken(bool noAction = false, bool isInsert = fal if (token.Type == SqlWordTokenType.String) { - this.SetWordColor(token); + if (!isDot) + { + this.SetWordColor(token); + } + return token; } } @@ -680,6 +708,7 @@ private SqlWordToken GetLastWordToken(bool noAction = false, bool isInsert = fal else if (isComment) { token.Type = SqlWordTokenType.Comment; + this.SetWordColor(token, true); } else if (long.TryParse(word, out _)) @@ -688,7 +717,7 @@ private SqlWordToken GetLastWordToken(bool noAction = false, bool isInsert = fal } else { - if (!isDot) + if (!isDot && !this.IsWordInQuotationChar(token)) { this.ClearStyle(token); } @@ -1070,4 +1099,4 @@ private void tsmiFindText_Click(object sender, EventArgs e) this.ShowFindBox(); } } -} +} \ No newline at end of file diff --git a/DatabaseManager/DatabaseManager.CoreApp/DatabaseManager.CoreApp.csproj b/DatabaseManager/DatabaseManager.CoreApp/DatabaseManager.CoreApp.csproj index b1100dd7..878b1789 100644 --- a/DatabaseManager/DatabaseManager.CoreApp/DatabaseManager.CoreApp.csproj +++ b/DatabaseManager/DatabaseManager.CoreApp/DatabaseManager.CoreApp.csproj @@ -8,12 +8,13 @@ victor-wiki Database manage tool for: SqlServer, MySql, Oracle and Postgres. https://github.com/victor-wiki/DatabaseManager - 2.0.24 + 2.0.25 Resources\_dbManager.ico - table desinger: auto update value when focus leave cell for data type column + bug fix: +handle query editor content that within single quotation chars AnyCPU;x64 - 2.0.24 - 2.0.24 + 2.0.25 + 2.0.25