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.

select with alias tablenames broken

#316

This worked before i upgraded to rails 2.1 (from 1.2.6) using mysql:

Model.find(:all,:conditions=>"1",:joins=>"as alias left join model2 as alias2 on alias.id = alias2.line_id")

To get it working you need to remove the alias or insert a custom select option:

Model.find(:all,select=>"*",:conditions=>"1",:joins=>"as alias left join model2 as alias2 on alias.id = alias2.line_id")

It seems that the later rails version add the default model tablename to the query e.g.:

select original_table_name.* from ...

That does not work because it needs the alias in the statement.

Is that a bug or a feature?

Reported by Martin Bosner · June 3rd, 2008 @ 02:57 PM

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

Activity

  1. Tarmo Tänav
    Tarmo Tänav
    • State changed from new to wontfix
    • Tag cleared.

    I believe this is a feature, we wouldn't want joins to mask any attribute without explicit user approval. For example if you join multiple tables and select "*" then it becomes unclear which table's "id" attribute should be returned.

    I'll close this for now, until convincing arguments are given for why this should be changed.

    August 23rd, 2008 @ 02:02 PM