Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combination of double quotes, asterisks, and GO command breaks deployment #3

Open
blevalley opened this issue Jul 27, 2018 · 0 comments · May be fixed by DbUp/DbUp#374
Open

Combination of double quotes, asterisks, and GO command breaks deployment #3

blevalley opened this issue Jul 27, 2018 · 0 comments · May be fixed by DbUp/DbUp#374
Labels
bug Something isn't working

Comments

@blevalley
Copy link

blevalley commented Jul 27, 2018

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
        }
    }
@droyad droyad added the bug Something isn't working label Aug 3, 2018
@sgoodgrove sgoodgrove linked a pull request Oct 17, 2018 that will close this issue
@droyad droyad transferred this issue from DbUp/DbUp Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Bugs
Development

Successfully merging a pull request may close this issue.

2 participants