Sorting, so ordering doesn't work as expected with postresql

I am developing a rails application which has its content in turkish language. I am using Postgresql 9.2.2 as my database. Everything works fine (no weird character issues, etc.), except for the correct ordering.

For example, when I try to list some items that are ordered by the city in which they are located, I expect something like "Adana, Bursa, Istanbul, Giresun, Zonguldak ..".

Instead, I always get Turkish specific characters at the end / beginning of the list. (ie "Adana, Bursa, Giresun, Zonguldak, Istanbul")

I initialized my postgres db with the command: initdb /usr/local/var/postgres -E utf8 --locale=tr_TR

when i am \l

in psql console i get expected.

 Name              Owner         Encoding   Collate   Ctype
 ----------------+-------------+----------+---------+-------+ 
 app_development | app         | UTF8     | tr_TR   | tr_TR |
 app_production  | app         | UTF8     | tr_TR   | tr_TR |
 app_test        | app         | UTF8     | tr_TR   | tr_TR |
 postgres        | monkegjinni | UTF8     | tr_TR   | tr_TR |

      

I also tried to create databases manually with LC_CTYPE="tr_TR.UTF-8"

and LC_COLLATE="tr_TR.UTF-8"

, and again there was no progress.

Some information about my development environment:

  • Running Mountain Lion 10.8.2 with Macbook Pro 7.1

  • psql --version

    : 9.2.2

  • rails --version

    : 3.2.11

$ locale

:

  • LANG = "tr_TR.UTF-8"
  • LC_COLLATE = "tr_TR.UTF-8"
  • LC_CTYPE = "tr_TR.UTF-8"
  • LC_MESSAGES = "tr_TR.UTF-8"
  • LC_MONETARY = "tr_TR.UTF-8"
  • LC_NUMERIC = "tr_TR.UTF-8"
  • LC_TIME = "tr_TR.UTF-8"
  • LC_ALL =

How can I solve this problem?

+3


source to share


1 answer


UTF-8 locales on OS X are broken. You can try to use a non-UTF-8 locale (tr_TR.ISO8859-9), but it seems to be broken in that regard as well. So it won't work.



+1


source







All Articles