Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions QueryBuilder.Tests/GeneralTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ public void Return_Different_MethodInfo_WhenSame_Method_With_Different_GenericTy
Assert.NotSame(call1, call2);
}

[Fact]
public void Custom_compiler_with_empty_identifier_overrides_should_remove_identifiers()
{
var compiler = new TestEmptyIdentifiersCompiler();

var wrappedValue = compiler.WrapValue("Table");

Assert.Equal("Table", wrappedValue);
}

[Fact]
public void Should_Equal_AfterMultipleCompile()
{
Expand Down
7 changes: 7 additions & 0 deletions QueryBuilder.Tests/Infrastructure/TestCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,11 @@ public virtual MethodInfo Call_FindCompilerMethodInfo(Type clauseType, string me
return FindCompilerMethodInfo(clauseType, methodName);
}
}

class TestEmptyIdentifiersCompiler : TestCompiler
{
protected override string OpeningIdentifier { get; set; } = "";
protected override string ClosingIdentifier { get; set; } = "";
}
}

2 changes: 2 additions & 0 deletions QueryBuilder/Compilers/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,8 @@ public virtual string WrapValue(string value)
var opening = this.OpeningIdentifier;
var closing = this.ClosingIdentifier;

if (string.IsNullOrWhiteSpace(opening) && string.IsNullOrWhiteSpace(closing)) return value;

return opening + value.Replace(closing, closing + closing) + closing;
}

Expand Down