Skip to content

'Less Than' prepare failing #193

Closed
Closed

Description

@alexrootes

Hi All, following the upgrade to 2.1 queries with less than operators are failing in NH.

Here is a test to replicate (put this in CommandTests.cs)

    [Test]
    public void LessThanInQueryStringWithPrepare()
    {
        var command = new NpgsqlCommand("select count(*) from data where field_serial <:param1", Conn);
        command.Parameters.AddWithValue(":param1", 1);
        command.Prepare();
        command.ExecuteScalar();
    }

ERROR: 42601: syntax error at or near ":"

This is because 'param1' is not replaced before being sent to the server.

This test is a direct copy of 'GreaterThanInQueryStringWithPrepare' which is the same file, which passes successfully!

Alex.

Activity

  1. changed the title [-]Npgsql 2.1 'Less Than' prepare failing[/-] [+]'Less Than' prepare failing[/+] on Mar 24, 2014
  2. alexrootes commented on Mar 25, 2014

    @alexrootes
    Author

    This seems like a pretty serious regression, possibly caused by PR #135 .

    I have reverted NpgsqlCommand.Rewrite.cs to a version before this time and the above test passes as it should.

    @glenebob does this sound like a possibility?

  3. glenebob commented on Mar 25, 2014

    @glenebob
    Contributor

    This sounds nasty :( And the mind boggles at how this could have made it
    through a beta cycle :(

    But, I'm betting it's a simple fix to the query rewriter. I will try to
    take a look and fix it in the next couple days.

    -Glen

    On Tue, Mar 25, 2014 at 4:43 AM, Alex Rootes [email protected]:

    This seems like a pretty serious regression possibly caused by PR #116#116
    .

    I have reverted NpgsqlCommand.Rewrite.cs to a version before this time and
    the above test passes as it should.

    @glenebob https://github.com/glenebob does this sound like a
    possibility?

    Reply to this email directly or view it on GitHubhttps://github.com//issues/193#issuecomment-38554567
    .

  4. franciscojunior commented on Mar 25, 2014

    @franciscojunior
    Member

    I agree with you. But I think this problem didn't appear before because if you add a space between the '<' and the parameter name, this problem doesn't appear.

  5. franciscojunior commented on Mar 28, 2014

    @franciscojunior
    Member

    @glenebob , while you are working in a permanent fix, I did a small change in current code which fix this issue but I think it breaks support added in #135 . As soon as you get your fix committed to master, I'll reapply to 2.1.x

    This is far from ideal solution, but it will allow people who is having problems with 2.1.1 to work with NHibernate.

  6. added a commit that references this issue on Mar 28, 2014
    86bd3f5
  7. franciscojunior commented on Mar 28, 2014

    @franciscojunior
    Member

    Just created a new release which contains a fix for this as I said before. Glen, when you have a permanent fix for this issue and #135, please, let me know so I can merge back to 2.1.x branch and upload a new release. Unless we end up releasing 2.2.x first.

    @alexrootes , please, give it a try and let me know if everything is working ok for you. Thanks in advance for your report.

  8. added 2 commits that reference this issue on Mar 29, 2014
  9. glenebob commented on Mar 29, 2014

    @glenebob
    Contributor

    Hi all,

    I just committed simplified and expanded tests for this into master, and
    what I believe is the "right" fix for it.

    Let's have a couple more sets of eyes look at it before we call it done and
    merge it to 2.1.

    Alex, can you verify that this fix works for you?

    -Glen

    On Thu, Mar 27, 2014 at 7:22 PM, Francisco Figueiredo Jr. <
    [email protected]> wrote:

    Just created a new release which contains a fix for this as I said before.
    Glen, when you have a permanent fix for this issue and #135#135,
    please, let me know so I can merge back to 2.1.x branch and upload a new
    release. Unless we end up releasing 2.2.x first.

    @alexrootes https://github.com/alexrootes , please, give it a try and
    let me know if everything is working ok for you. Thanks in advance for your
    report.

    Reply to this email directly or view it on GitHubhttps://github.com//issues/193#issuecomment-38883158
    .

  10. alexrootes commented on Mar 30, 2014

    @alexrootes
    Author

    Thanks for this Glen,

    I have retested with the latest master and I can confirm this issue appears to be resolved for me.

    Alex.

  11. glenebob commented on Mar 30, 2014

    @glenebob
    Contributor

    @alexrootes,

    Excellent! Thank you for testing it for us.

    -Glen

  12. added a commit that references this issue on Apr 5, 2014
  13. glenebob commented on Apr 5, 2014

    @glenebob
    Contributor

    Fixed in master and 2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions