generated from DbUp/dbup-provider-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Open
DbUp/DbUp
#374Labels
bugSomething isn't workingSomething isn't working
Description
If a script both selects a column as a name using double quotes (i.e. SELECT 1 AS "Test/*") and uses a GO command, the upgrade process will fail with message 'Incorrect syntax near GO'. Removing the GO command, or converting the double quotes to either single quotes or square brackets fixes the issue.
Tested on SqlServer 2016 and 2017.
Code to reproduce:
static void Main(string[] args)
{
var connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
/*
* SELECT 'Test' AS "Test/*"
* GO
*/
var sql = "SELECT 'Test' AS \"Test/*\"\nGO";
var script = new DbUp.Engine.SqlScript("Tester", sql);
var builder = DbUp.DeployChanges.To
.SqlDatabase(connectionString)
.JournalTo(new NullJournal())
.WithScripts(script)
.WithTransaction()
.LogToConsole()
.Build();
var result = builder.PerformUpgrade();
Debug.Assert(!result.Successful); // Fails
/*
* SELECT 'Test' AS "Test/*"
*/
sql = "SELECT 'Test' AS \"Test/*\"";
script = new DbUp.Engine.SqlScript("Tester", sql);
builder = DbUp.DeployChanges.To
.SqlDatabase(connectionString)
.JournalTo(new NullJournal())
.WithScripts(script)
.WithTransaction()
.LogToConsole()
.Build();
result = builder.PerformUpgrade();
Debug.Assert(result.Successful); // Succeeds
/*
* SELECT 'Test' AS 'Test/*'
* GO
*/
sql = "SELECT 'Test' AS 'Test/*'\nGO";
script = new DbUp.Engine.SqlScript("Tester", sql);
builder = DbUp.DeployChanges.To
.SqlDatabase(connectionString)
.WithScripts(script)
.JournalTo(new NullJournal())
.WithTransaction()
.LogToConsole()
.Build();
result = builder.PerformUpgrade();
Debug.Assert(result.Successful); // Succeeds
}
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Bugs