Fix EXIST handling in regards to line breaks. (#117) (#118)

pull/119/head
Laurents Meyer 4 years ago committed by GitHub
parent e9d4aef876
commit 1eb7ec7793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,7 +25,7 @@ namespace EntityFrameworkCore.Jet.Data
private static readonly Regex _outerSelectTopValueRegularExpression = new Regex(@"(?<=^\s*select\s+top\s+)\d+(?=\s)", RegexOptions.IgnoreCase);
private static readonly Regex _outerSelectSkipValueOrParameterRegularExpression = new Regex(@"(?<=^\s*select)\s+skip\s+(?<SkipValueOrParameter>@\w+|\?|\d+)(?=\s)", RegexOptions.IgnoreCase);
private static readonly Regex _selectRowCountRegularExpression = new Regex(@"^\s*select\s*@@rowcount\s*;?\s*$", RegexOptions.IgnoreCase);
private static readonly Regex _ifStatementRegex = new Regex(@"^\s*if\s*(?<not>not)?\s*exists\s*\((?<sqlCheckCommand>.+)\)\s*then\s*(?<sqlCommand>.*)$", RegexOptions.IgnoreCase);
private static readonly Regex _ifStatementRegex = new Regex(@"^\s*if\s*(?<not>not)?\s*exists\s*\((?<sqlCheckCommand>.+)\)\s*then\s*(?<sqlCommand>.*)$", RegexOptions.IgnoreCase | RegexOptions.Singleline);
protected JetCommand(JetCommand source)
{

@ -0,0 +1,38 @@
using System.Data.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace EntityFrameworkCore.Jet.Data.Tests
{
[TestClass]
public class ExistsTest
{
private const string StoreName = nameof(ExistsTest) + ".accdb";
private JetConnection _connection;
[TestInitialize]
public void Setup()
{
_connection = Helpers.CreateAndOpenDatabase(StoreName);
}
[TestCleanup]
public void TearDown()
{
_connection?.Close();
Helpers.DeleteDatabase(StoreName);
}
[TestMethod]
public void IfExists()
{
using var command = _connection.CreateCommand(
@"IF NOT EXISTS (SELECT * FROM `INFORMATION_SCHEMA.TABLES` WHERE `TABLE_NAME` = '__EFMigrationsHistory') THEN CREATE TABLE `__EFMigrationsHistory` (
`MigrationId` varchar(150) NOT NULL,
`ProductVersion` varchar(32) NOT NULL,
CONSTRAINT `PK___EFMigrationsHistory` PRIMARY KEY (`MigrationId`)
)");
command.ExecuteNonQuery();
}
}
}
Loading…
Cancel
Save