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

Question mark in 'Like' statements #436

Open
oleksandr-sidenko opened this issue Dec 15, 2020 · 3 comments
Open

Question mark in 'Like' statements #436

oleksandr-sidenko opened this issue Dec 15, 2020 · 3 comments

Comments

@oleksandr-sidenko
Copy link

I have an issue when try to use "?" not as a parameter in the 'Like' statement, but as part of word. For example "message like '%blabla?%". Currently I got an exception because 'Sqlkata' uses question mark as a parameter placeholder. So I need a way to escape question mark. Or, actually, when I opened the source code of 'Complier.cs' I found something interesting. Here we have:
protected virtual string parameterPlaceholder { get; set; } = "?";

It is good opportunity to override it and use some other symbol or even word for the binding parameter, but, for some reason this property isn't used elsewhere. For example:

ctx.RawSql = Helper.ExpandParameters(ctx.RawSql, "?", ctx.Bindings.ToArray());

case Variable variable2:
    object variable1 = ctx.Query.FindVariable(variable2.Name);
    ctx.Bindings.Add(variable1);
    return "?";
default:
    ctx.Bindings.Add(parameter);
    return "?";

So could you please reuse 'parameterPlaceholder' parameter in all other places so that it can only be changed in one place, without having to override all of these methods? Or add possibility to escape it in queries

@mykola-klymyuk-eleks
Copy link

Would like to see it processed too or at least to see a workaround for this.

@klym1
Copy link

klym1 commented Dec 16, 2020

Someone, anyone?

@Steven-Beasley
Copy link

Steven-Beasley commented Dec 20, 2020

I think you are looking for this.

new Query("Table").WhereLike("Column", @"%blabla\?%", escapeCharacter=@"\")

If the escaping isn't happening as a priority then that is a bug, and should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants