Most database ship with locales built in so they are consistent across installations.
Postgres does not ship with locales so it uses the ones in the operating system.
In the locales there is collation, which basically defines how to sort. We will mostly
notice this in the following 2 ways:
- case sensitive sorting
- include symbols in the sorting
case sensitive: "B", "E", "c", "d"
non-case Insensitive: "B", "c", "d", "E"
include symbols: "Sams Golf Shop", "Sam's Cantina"
ignore symbols: "Sam's Cantina", "Sams Golf Shop"
In our domain, the ignoring symbols causes some issues:
include symbols: "1/2/3", "1/2/5", "1/4", "12/4"
ignore symbols: "1/2/3", "12/4", "1/2/5", "1/4" (think alphabetic sort: "123", "125", "14", 124")
If you are ordering them to put into a tree, then this gets confusing and
can result in children coming back out of order. This is tricky for arrange.
An option was introduced for the case when symbols are not considered. It essentially
'join' the strings together to simulate ignoring the symbols.
Also do remember, that this is sorting alphabetically rather than numerically. So 14 > 123.
Our team is going though the process of upgrading Rails and ran into the issue that type_for_attribute was undefined. After some investigation, we found that type_for_attribute was added in Rails 4.2 and was not defined previously.
Admittedly the documentation for `<Model>.arrange` took a couple thought cycles before I figured out the resulting data structure. I've added another node to the example to illustrate multiple siblings on one level, and fussed with the code style to be a bit easier to grok.