Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Failing when requesting siblings #8

Merged
merged 1 commit into from Jun 11, 2012

Conversation

Projects
None yet
2 participants
Contributor

eljojo commented Jun 4, 2012

Hi,
closure_tree was crashing when requesting siblings for a specific row.

1.9.3-p125 :006 > creativity = Tag.find 10
Tag Load (0.4ms) SELECT tags.* FROM tags WHERE tags.id = 10 ORDER BY tags.title ASC LIMIT 1
=> #<Tag id: 10, title: "creativity", description: "", created_at: "2012-04-17 11:59:18", updated_at: "2012-06-04 16:25:01", parent_id: 26, slug: "creativity">
1.9.3-p125 :008 > creativity.parent
Tag Load (0.4ms) SELECT tags.* FROM tags WHERE tags.id = 26 ORDER BY tags.title ASC LIMIT 1
=> #<Tag id: 26, title: "art", description: "", created_at: "2012-04-17 11:59:18", updated_at: "2012-06-04 16:21:00", parent_id: nil, slug: "art">
1.9.3-p125 :009 > creativity.siblings
Tag Load (0.6ms) SELECT tags.* FROM tags WHERE tags.parent = 26 AND (tags.id != 10) ORDER BY tags.title ASC
ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'tags.parent' in 'where clause': SELECT tags.* FROM tags WHERE tags.parent = 26 AND (tags.id != 10) ORDER BY tags.title ASC

Good catch, and thanks for the pull request!

We obviously need a test for siblings() -- I'll be able to get to that in a day or two, unless you can throw it together.

Owner

eljojo replied Jun 6, 2012

mceachen added a commit that referenced this pull request Jun 11, 2012

Merge pull request #8 from eljojo/master
Failing when requesting siblings. Tests forthcoming.

@mceachen mceachen merged commit adfadd9 into ClosureTree:master Jun 11, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment