-
-
Save anonymous/ee94694a0d3c617cc236bc479fdd399f to your computer and use it in GitHub Desktop.
bug in StatementPreparer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using MySql.Data.MySqlClient; | |
using MySqlConnector.Core; | |
using Xunit; | |
namespace MySqlConnector.Tests | |
{ | |
public class StatementPreparerTests | |
{ | |
[Theory] | |
[InlineData(GoodSqlText)] | |
[InlineData(AnotherGoodSqlText)] | |
[InlineData(BadSqlText)] | |
public void PrepareQuery(string sql) | |
{ | |
var parameters = new MySqlParameterCollection(); | |
parameters.AddWithValue("c2", 3); | |
var parsedRequest1 = System.Text.Encoding.Default.GetString(new StatementPreparer(sql, parameters, StatementPreparerOptions.None).ParseAndBindParameters().Array); | |
Assert.Matches("column2 = 3", parsedRequest1); | |
} | |
private const string BadSqlText = @"SELECT | |
Id | |
FROM mytable | |
WHERE column1 = 2 -- mycomment | |
AND column2 = @c2"; | |
private const string GoodSqlText = @"SELECT | |
Id | |
FROM mytable | |
WHERE column1 = 2 | |
AND column2 = @c2"; | |
private const string AnotherGoodSqlText = @"SELECT | |
Id | |
FROM mytable | |
WHERE column1 = 2 -- mycomment | |
AND column2 = @c2"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment