#432 ✓resolved
Ana Nelson

lazy loading associations reloading bug

Reported by Ana Nelson | July 2nd, 2008 @ 08:26 AM

This is a really odd intermittent bug which I'm having a hard time tracking down to give a decent bug report. I've done all I have time for today, if I can I will update this later.

The error message I get is this:

PostgresError: ERROR: IN types timestamp without time zone and integer cannot be matched

and this is caused by this query:

SELECT "context_id", "id" FROM "tasks" WHERE "completed_at" IN ((2), (2)) AND "project_id" IN (2) AND "waiting_for_id" IS NULL AND "id" IN (2, 37) ORDER BY "id"

completed_at is a DateTime field, but I think it's picking up the project_id value for some reason.

This is caused by trying to access task.context on a tasks collection created like this:

Task.all(:completed_at => nil, :waiting_for_id => nil, :order => [:context_id])

So, we are looking for completed_at => nil. When I iterate over the collection and ask for .context, the array gets reloaded since .context_id wasn't queried for originally, but the conditions get messed up as above and we get the error.

For some incredibly frustrating reason, this doesn't happen every time, only sometimes, so it's hard for me to narrow this down to a minimal reproducible example. :-)

I have attached a stack trace and the result of some puts statements I added to the code. I updated my dm from the git repo this morning.

Comments and changes to this ticket

  • deepfryed

    deepfryed July 7th, 2008 @ 08:03 AM

    I encountered something similar although it only shows up when I use dm-validations (see attached file)

    Additionally, changing the property ordering also seems to hide the problem. Am I missing something

    obvious, rookie mistake ??

    --- test.rb 2008-07-07 20:52:54.000000000 +0800

    +++ test.rb 2008-07-07 21:01:27.000000000 +0800

    @@ -12,8 +12,8 @@

    property :user_id, Integer

    property :text, String, :nullable => false

    property :updated, DateTime, :nullable => false, :default => Time.now

    • property :deleted, ParanoidDateTime

    property :reliability, Integer, :default => 0

    • property :deleted, ParanoidDateTime

    belongs_to :user

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) July 9th, 2008 @ 10:30 PM

    Ana, I think this might've been due to an SEL bug that I just fixed a moment ago. Can you sync up and let me know if it fixed this problem for you?

  • Ana Nelson

    Ana Nelson July 10th, 2008 @ 04:00 AM

    Dan,

    Yes this seems to be fixed now, thanks.

    -Ana

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) July 10th, 2008 @ 07:59 AM

    • State changed from “new” to “resolved”

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

Attachments

Pages