#275 ✓resolved
Adam French

passing nil as parameter to query causes bad query

Reported by Adam French | May 11th, 2008 @ 11:29 PM

It seems that doing

SailBoat.first(:name => 'something', :port.not => nil)

Renders a query that looks like

SELECT "id", "name", "port" FROM "sail_boats" WHERE ("port" IS NOT NULL) AND ("name" = NULL) LIMIT 1

'DataMapper::Query when ordering should find by conditions' FAILED

expected not nil, got nil

/Users/afrench/src/dm/dm-core/spec/integration/query_spec.rb:45:

/Users/afrench/src/dm/dm-core/lib/data_mapper.rb:168:in `repository'

/Users/afrench/src/dm/dm-core/lib/data_mapper/support/kernel.rb:5:in `repository'

/Users/afrench/src/dm/dm-core/spec/integration/query_spec.rb:38:

spec is in my recent push

Comments and changes to this ticket

  • John W Higgins

    John W Higgins May 12th, 2008 @ 12:32 AM

    I've patched dm-core with at least a temporary fix - this has raised some issues with the way queries are created but this certainly at least works for the moment

    http://github.com/sam/dm-core/co...

  • Sam Smoot
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) June 2nd, 2008 @ 07:52 PM

    • State changed from “new” to “resolved”

    This is no longer an issue. John's commit was updated so that the bind values matched the placeholders in all of the queries the DO adapters generate. The way he compacts the parameters isn't necessary and is no longer in the code.

    In the commit above, I commented that I thought the statement and bind values should be returned by the method that generates the statement. While this would certainly have prevented this issue from occurring, its not really necessary any longer now that placeholders and bind values line-up in all cases.. and would probably have resulted in more code anyway.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Pages