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

Handle decimal in query expressions #764

Closed
4 tasks done
josevalim opened this issue Jul 9, 2015 · 4 comments
Closed
4 tasks done

Handle decimal in query expressions #764

josevalim opened this issue Jul 9, 2015 · 4 comments

Comments

@josevalim
Copy link
Member

For @elixir-lang/ecto-adapters,

  • MySQL
  • Postgres
  • MSSQL
  • SQLite

It is just a matter of adding this clause: f96e602#diff-975ad8a7b1f8e27ac59595bcdbdd0a07R355

@mobileoverlord
Copy link
Contributor

MSSQL: livehelpnow/tds_ecto@8d1c9f8

jazzyb added a commit to jazzyb/sqlite_ecto that referenced this issue Jul 9, 2015
@jazzyb
Copy link
Contributor

jazzyb commented Jul 9, 2015

Couple of questions:

Firstly, I'm trying to write a unit test for the Decimal case, but this code:

  test "decimals" do
    query = Model |> select([], Decimal.new(123.0)) |> normalize
    assert SQL.all(query) == ~s{SELECT 123.0 FROM "model" AS m0}
  end

gives me this error:

** (Ecto.Query.CompileError) `Decimal.new(123.0)` is not a valid query expression
    (ecto) expanding macro: Ecto.Query.select/3
    test/sqlite_ecto_test.exs:425: Sqlite.Ecto.Test."test decimals"/1
    (elixir) expanding macro: Kernel.|>/2
    test/sqlite_ecto_test.exs:425: Sqlite.Ecto.Test."test decimals"/1

What is an example query expression I could use to test the Decimal change?

Secondly, I'm getting the following error when I try to run integration tests with the newest commit in master:

** (ArgumentError) argument error
    (stdlib) :lists.keyfind(:adapter, 1, [{:pool, Ecto.Pools.Poolboy}, {:size, 1} | nil])
    (elixir) lib/access.ex:49: Access.List.get/2
    (ecto) lib/ecto/repo/config.ex:10: Ecto.Repo.Config.parse/2
    deps/ecto/integration_test/cases/pool.exs:16: (module)
    deps/ecto/integration_test/cases/pool.exs:15: (module)

Code is here. I looked at the changes to the test_helper.exs scripts for Postgres and MySQL, and I don't see any obvious differences. Any ideas what the problem is?

@josevalim
Copy link
Member Author

Firstly, I'm trying to write a unit test for the Decimal case, but this code:

You don't need to write one as we already have tests in the integration_test/cases/types.exs. Something like:

from p in Post, where: p.some_decimal == 1.0

will convert 1.0 to Decimal.

Code is here. I looked at the changes to the test_helper.exs scripts for Postgres and MySQL

Maybe an issue based on how things are being loaded? I have improved the error message but the issue is that it can't find the config for Ecto.Integration.TestRepo.

@jazzyb
Copy link
Contributor

jazzyb commented Jul 9, 2015

Thanks for the help, José!

I had Application.put_env(:sqlite_ecto, ... instead of Application.put_env(:ecto, ... for both TestRepo and PoolRepo. I don't know how I got away with that one for so long.

SQLite: jazzyb/sqlite_ecto@a2a48d8

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

No branches or pull requests

3 participants