drewolson / scrivener

Pagination for the Elixir ecosystem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Array type is not supported by MySQL

philnash opened this issue · comments

Hi, I'm new to Elixir so trying to add small features to applications right now. Please excuse me if this is totally dumb, but I've spent a while trying to debug and I'm lost.

I started to work on rrrene/elixirstatus-web#13 which was to add pagination using Scrivener. Here is what I've done: rrrene/elixirstatus-web@master...philnash:pagination. I hoped that it would be mostly as simple as adding Scrivener and changing the call to Repo.all to Repo.paginate in the PostingsController. However, I get the error Array type is not supported by MySQL. The full stack trace is below:

[error] #PID<0.490.0> running ElixirStatus.Endpoint terminated
Server: localhost:4000 (http)
Request: GET /postings
** (exit) an exception was raised:
    ** (ArgumentError) Array type is not supported by MySQL
        (ecto) lib/ecto/adapters/mysql/connection.ex:352: Ecto.Adapters.MySQL.Connection.expr/2
        (elixir) lib/enum.ex:1008: anonymous fn/4 in Enum.map_join/3
        (elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
        (elixir) lib/enum.ex:1007: Enum.map_join/3
        (ecto) lib/ecto/adapters/mysql/connection.ex:347: Ecto.Adapters.MySQL.Connection.expr/2
        (elixir) lib/enum.ex:1008: anonymous fn/4 in Enum.map_join/3
        (elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
        (elixir) lib/enum.ex:1007: Enum.map_join/3

I can understand MySQL not being able to do some things, but this seems like a simple use case and I can't tell where or how I am trying to use the Array type.

Any help would be gladly received. Thanks.

Thanks for reporting this. My only suspicion at this point would be the way we're performing the count[1]. I'll try to look into it more later today.

[1] - https://github.com/drewolson/scrivener/blob/master/lib/scrivener.ex#L153

@philnash on closer inspection, it appears Ecto may not support the array type for MySQL[1]. Perhaps @josevalim or @ericmj would have a better idea.

[1] - https://github.com/elixir-lang/ecto/blob/master/lib/ecto/adapters/mysql/connection.ex#L342-L344

Yes, MySQL does not support arrays but count should not be the one triggering it. @drewolson can you please run your tests with MySQL too (maybe add it to travis) and let us know which query exactly is failing? Thanks everyone!

I have opened an issue in ecto to improve the error message.

I have an idea! To the fork-mobile!

"fork-mobile" - I am cracking up

Best issue thread ever. @josevalim I'll attempt to get tests running on MySQL in Travis today.