Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BIT(1) type cannot load <<1>> as type :boolean #1366

Closed
paulgithub opened this issue Apr 12, 2016 · 1 comment
Closed

BIT(1) type cannot load <<1>> as type :boolean #1366

paulgithub opened this issue Apr 12, 2016 · 1 comment

Comments

@paulgithub
Copy link
Contributor

Precheck

When reading a boolean value from the database which is represented as a BIT(1) in the MySQL server (version 5.5.29) and using this value in model as a :boolean

There is a suggested fix for this on the mariaex github issue: xerions/mariaex#107 that works.

Environment

  • Elixir version (elixir -v): 1.2.3
  • Database and version (PostgreSQL 9.4, MongoDB 3.2, etc.): MySQL version 5.5.29
  • Ecto version (mix deps): 1.1.4
  • Database adapter and version (mix deps): mariaex version 0.7.3
  • Operating system: OSX

Current behavior

error / stacktrace

** (exit) an exception was raised:
** (ArgumentError) cannot load <<1>> as type :boolean
(ecto) lib/ecto/schema.ex:982: Ecto.Schema.load!/3
(ecto) lib/ecto/schema.ex:974: anonymous fn/3 in Ecto.Schema.do_load/4
(elixir) lib/enum.ex:1473: Enum."-reduce/3-lists^foldl/2-0-"/3
(ecto) lib/ecto/schema.ex:972: Ecto.Schema.do_load/4
(ecto) lib/ecto/schema.ex:957: Ecto.Schema.load/6
(ecto) lib/ecto/adapters/sql.ex:519: anonymous fn/3 in Ecto.Adapters.SQL.process_row/3
(elixir) lib/enum.ex:1151: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(ecto) lib/ecto/adapters/sql.ex:513: Ecto.Adapters.SQL.process_row/3
(elixir) lib/enum.ex:1088: Enum."-map/2-lists^map/1-0-"/2
(ecto) lib/ecto/adapters/sql.ex:283: Ecto.Adapters.SQL.decode/2
(stdlib) timer.erl:166: :timer.tc/1
(ecto) lib/ecto/adapters/sql.ex:278: Ecto.Adapters.SQL.decode/3
(ecto) lib/ecto/adapters/sql.ex:225: Ecto.Adapters.SQL.query/5
(ecto) lib/ecto/adapters/sql.ex:183: Ecto.Adapters.SQL.query!/5
(ecto) lib/ecto/adapters/sql.ex:481: Ecto.Adapters.SQL.execute/6
(ecto) lib/ecto/repo/queryable.ex:95: Ecto.Repo.Queryable.execute/5
(ecto) lib/ecto/repo/queryable.ex:15: Ecto.Repo.Queryable.all/4
(ecto) lib/ecto/repo/queryable.ex:44: Ecto.Repo.Queryable.one/4

Expected behavior

The BIT(1) should be translated as a boolen and not a number

@josevalim
Copy link
Member

Beautiful, can you please send a PR? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants