Skip to content

Commit

Permalink
Fixed LIKE escaping issues
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Sep 25, 2018
1 parent dd2467c commit 8340fa1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
4 changes: 2 additions & 2 deletions dg.Sql.Connector.MySql/MySqlConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ public override string FormatDate(DateTime dateTime)

public override string EscapeLike(string expression)
{
return expression.Replace(@"'", @"''").Replace(@"%", @"%%");
return expression.Replace("%", "\x10%");
}

public override string LikeEscapingStatement
{
get { return @"ESCAPE('\\')"; }
get { return "ESCAPE('\x10')"; }
}

#endregion
Expand Down
11 changes: 2 additions & 9 deletions dg.Sql.Connector.PostgreSQL/PostgreSQLConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,14 @@ public override string FormatDate(DateTime dateTime)

public override string EscapeLike(string expression)
{
return expression.Replace(@"_", @"\_").Replace(@"%", @"\%");
return expression.Replace(@"_", @"\x10_").Replace(@"%", @"\x10%");
}

public override string LikeEscapingStatement
{
get
{
if (GetPostgreSQLMode().StandardConformingStrings)
{
return @"ESCAPE('\')";
}
else
{
return @"ESCAPE('\\')";
}
return "ESCAPE('\x10')";
}
}

Expand Down

0 comments on commit 8340fa1

Please sign in to comment.