Ecto: Ecto is not supporting local languages while inserting into Mysql

Created on 24 Aug 2016  ·  5Comments  ·  Source: elixir-ecto/ecto

Precheck

I am trying to insert one indian language string into mysql database using Repo.insert, but in database that value of that column showing like ???????????????

while creating database in mysql i am using ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; for unicode support, and inside elixir model i am using column type as string( field :displayname, :string )

I am not sure Ecto supports other than english language while insert into DB, need support from anybody how to do that.

Environment

  • Elixir version (Elixir 1.3.2):
  • Database and version (MySQL 5.6.27 ):
  • Ecto version (1.1.9):
  • Database adapter and version (mariaex 0.7.7 ):
  • Operating system: Ubuntu 14.04.3 LTS

    Current behavior

String : ಆಗ್ತಾಇಲ್ಲ
After insert into mysql db using Repo.insert, in DB it is showing like ???????

Expected behavior

String : ಆಗ್ತಾಇಲ್ಲ
After insert into mysql db using Repo.insert, in DB it should show ಆಗ್ತಾಇಲ್ಲ

Most helpful comment

For anyone else struggling with this, just add

binary_as: :field_type_blob

to your connection config and it solves this issue.

All 5 comments

This seems like an issue with mysql or the elixir driver mariaex. Ecto just passes the utf8 strings along to the driver.

@ok-madan yes, please file an issue on https://github.com/xerions/mariaex. Please include the mariaex version (it can be found in mix deps) and some sample commands in your report.

@ericmj , @josevalim Thanks for quick response and clarified my issue, i will create issue at mariaex repo.

I had the same issue and it was resolved after I set the value of the locale environment variable LC_ALL. Please check https://samueltthomas.com/setting-locale-for-fixing-unicode-issue-for-elixir for more info

For anyone else struggling with this, just add

binary_as: :field_type_blob

to your connection config and it solves this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kelostrada picture kelostrada  ·  3Comments

nathanjohnson320 picture nathanjohnson320  ·  4Comments

AndresOsinski picture AndresOsinski  ·  5Comments

brandonparsons picture brandonparsons  ·  3Comments

ZhengQingchen picture ZhengQingchen  ·  4Comments