From: Mikhail Yakshin <greycat@altlinux.org>
To: ALT Linux Sisyphus discussions <sisyphus@lists.altlinux.org>
Subject: Re: [sisyphus] странное и некрасивое поведение utf8 в паре rails/mysql
Date: Sun, 28 Jun 2009 10:16:19 +0400
Message-ID: <240e377b0906272316n5233c43fn2a807c73f3a3e23b@mail.gmail.com> (raw)
In-Reply-To: <69c7dc8b0906260330o462070r66569e1a87b31cdc@mail.gmail.com>
> MySQL продолжает упорствовать в своих заблуждениях.
>
[...]
> Dict.find_by_word "ᾆδω"
> => #<Dict id: 2622, parent_id: nil, group_id: nil, variant_id: nil, word: "ἄδω"
>
> но "ᾆδω" это не "ἄδω" совсем.
>
> Интересно, может быть постгрес будет проще настроить?
Это unicode case-insensitive (ci) collation, который вполне себе
корректно отрабатывает. С точки зрения unicode - это два символа,
которые равны по sort values - т.к. и "ᾆ", и "ἄ" равны просто "α":
mysql> select 'ᾆ'='α';
+------------+
| 'ᾆ'='α' |
+------------+
| 1 |
+------------+
Это в целом полезный механизм - например, пользователь может написать
"елка", и оно из-за этого case insensitivity смэтчится со словами
"ёлка", "Елка" или "Ёлка", которые найдутся в базе.
Более подробно об этом можно почитать в руководстве MySQL:
http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html
Quick solution, если надо просто отключить любые case- и sort-
sensitivity - использовать тип BINARY (или collation utf8_bin). Их
можно поставить на БД целиком, на таблицы/поля/переменные или даже
индивидуальные сравнения:
mysql> select 'ᾆ' COLLATE utf8_bin='α';
+-----------------------------+
| 'ᾆ' COLLATE utf8_bin='α' |
+-----------------------------+
| 0 |
+-----------------------------+
Postgresql в данном случае будет вести себя точно так же - эти вещи
(классы эквивалентности по sort value для различных characters)
прописаны в стандарте unicode.
P.S. Вопрос, видимо, всё-таки не имеет отношения к sisyphus@ -
предлагаю переместиться в личную почту для дальнейших обсуждений, если
таковые будут иметь место.
--
WBR, Mikhail Yakshin
next prev parent reply other threads:[~2009-06-28 6:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-24 16:31 Michael Bykov
2009-06-25 6:57 ` Anton V. Boyarshinov
2009-06-26 10:30 ` Michael Bykov
2009-06-28 6:16 ` Mikhail Yakshin [this message]
2009-06-28 6:55 ` Michael Bykov
2009-06-28 8:41 ` Afanasov Dmitry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=240e377b0906272316n5233c43fn2a807c73f3a3e23b@mail.gmail.com \
--to=greycat@altlinux.org \
--cc=sisyphus@lists.altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
ALT Linux Sisyphus discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/sisyphus/0 sisyphus/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 sisyphus sisyphus/ http://lore.altlinux.org/sisyphus \
sisyphus@altlinux.ru sisyphus@altlinux.org sisyphus@lists.altlinux.org sisyphus@lists.altlinux.ru sisyphus@lists.altlinux.com sisyphus@linuxteam.iplabs.ru sisyphus@list.linux-os.ru
public-inbox-index sisyphus
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.sisyphus
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git