Add support for using generic SQL queries to filter EditData rows. (#605)

This commit is contained in:
Cory Rivera
2018-05-02 10:13:47 -07:00
committed by GitHub
parent 5a55e8b35c
commit 7415c529f3
13 changed files with 300 additions and 11 deletions

View File

@@ -18,7 +18,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility.SqlScriptFormatters
{
// Regex: optionally starts with N, captures string wrapped in single quotes
private static readonly Regex StringRegex = new Regex("^N?'(.*)'$", RegexOptions.Compiled);
private static readonly Regex BracketRegex = new Regex(@"^\[(.*)\]$", RegexOptions.Compiled);
/// <summary>
/// Decodes a multipart identifier as used in a SQL script into an array of the multiple
/// parts of the identifier. Implemented as a state machine that iterates over the
@@ -128,6 +129,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility.SqlScriptFormatters
return literal;
}
/// <summary>
/// Tests whether an identifier is escaped with brackets e.g. [Northwind].[dbo].[Orders]
/// </summary>
/// <param name="identifer">Identifier to check.</param>
/// <returns>Boolean indicating if identifier is escaped with brackets.</returns>
public static bool IsIdentifierBracketed(string identifer) => BracketRegex.IsMatch(identifer);
#region Private Helpers
private static bool HasNextCharacter(string haystack, char needle, int position)
@@ -143,7 +151,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility.SqlScriptFormatters
// Replace 2x of the escape character with 1x of the escape character
return value.Replace(new string(escapeCharacter, 2), escapeCharacter.ToString());
}
#endregion
}
}