Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Invalid SQL Generated by Mixed Relative / Qualified Conditions in ActiveRecord

#3359

If you mix relative and fully qualified conditions in ActiveRecord, your in for random results with the potential for invalid SQL.

The problem lies in the base method sanitize_sql_hash_for_conditions that generates the fully qualified SQL statements. It takes a “default” table name that’s used for unqualified conditions, however it overwrites this variable if it comes across an fully qualified condition. This means that the generation of the SQL depends on the internal order of the hash resulting in unpredictable output.

The fix for this is simply to ensure that fully qualified conditions don’t overwrite the default for relative conditions, the attached patch achieves this.

More info on this issue is available here:
http://blog.multiplay.co.uk/2009/10/invalid-sql-generated-by-mixed-...

Reported by Steven Hartland · October 9th, 2009 @ 11:59 AM

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to stale
    • Importance changed from to

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

    October 6th, 2010 @ 06:38 AM