I have a query which manually sets :links to join a table, such as:

Article.all(:links => [:readers], :conditions => ["readers.alive = ?", true])

This works fine and joins as expected.

However, if I chain this with another query which also sets :links
either explicitly as above, or implicitly by having something like:

Article.all('author.name' => 'Michael')

Then it fails because one stomps on the other's join SQL.

Eg:

Article.all(:links => [:readers], :conditions => ["readers.alive = ?",
true]).all('author.name' => 'Michael')

Produces something like:

SELECT articles.*
FROM articles
INNER JOIN authors ON articles.author_id = authors.id
WHERE authors.name = 'Michael'
AND readers.alive = TRUE

(note the lack of a join on the readers table, but still has the
condition meaning the query fails)

And the other way round:

SELECT articles.*
FROM articles
INNER JOIN readers ON articles.readers_id = reader.id
WHERE authors.name = 'Michael'
AND readers.alive = TRUE

This time it lacks the authors join.

It looks like all other parts of the query remain intact, but the
:links gets lost along the way.

This is all currently from memory, I'll work up a proper example later today.

I'm using dm 0.9.11, so this may well be fixed in 0.9.12 or 0.10.0 - I
haven't had a chance to upgrade to test yet.

Thanks.

-- 
Richard Livsey
Minutebase - Online Meeting Minutes
http://minutebase.com
http://livsey.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to