Toxic Elephant

Don't bury it in your back yard!

Materialized Path to Nested Set

Posted by matijs 13/12/2010 at 23h14

On twitter, @clemensk asks:

Hey SQL experts, is it somehow possible in pure (My)SQL to extract a nested set from a table full of paths (think: Category 1 > Category 2)?

To do this, you need to do two things: Extract the names of the nodes, and calculate values for lft and rgt. Here’s my take on the latter part:

Tags no comments no trackbacks

Redefined Accessors

Posted by matijs 10/12/2010 at 09h29

If you’re going to do this:

<typo:code lang=“ruby”> def foo= f @foo = f + “ bar” end </typo:code>

Then don’t first do this:

<typo:code lang=“ruby”> attr_accessor :foo </typo:code>

But instead do this:

<typo:code lang=“ruby”> attr_reader :foo </typo:code>

That way, there won’t be “method redefined” warnings all over the place.

Let’s make this more general: Before you release your gem, make sure it runs without warnings. They should stick out like a sore thumb when you run your tests, anyway.

Thanks.

Tags no comments no trackbacks