Skip to content

Fix access to firebird procedures #530

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions QueryBuilder.Tests/SelectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ public void BasicSelect()
Assert.Equal("SELECT \"ID\", \"NAME\" FROM \"USERS\"", c[EngineCodes.Firebird]);
Assert.Equal("SELECT \"id\", \"name\" FROM \"users\"", c[EngineCodes.Oracle]);
}

[Fact]
public void BasicSelectFromProcedure()
{
var q = new Query().From("users(5)");
var c = Compile(q);

Assert.Equal("SELECT * FROM \"USERS\"(5)", c[EngineCodes.Firebird]);
}

[Fact]
public void BasicSelectEnumerable()
Expand Down
8 changes: 7 additions & 1 deletion QueryBuilder/Compilers/FirebirdCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ protected override string CompileBasicDateCondition(SqlResult ctx, BasicDateCond

public override string WrapValue(string value)
{
return base.WrapValue(value).ToUpperInvariant();
if (value == "*") return value;

var opening = this.OpeningIdentifier;
var closing = this.ClosingIdentifier;

return Regex.Replace(value.Replace(closing, closing + closing), @"^(?<a1>[\w]+)(?<a2>(\(.+))*$",
p => opening + p.Groups["a1"].Value.ToUpperInvariant() + closing + p.Groups["a2"].Value);
}

public override string CompileTrue()
Expand Down