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

Using Ecto Adapter in a phoenix web application #4

Closed
mukulashokjoshi opened this Issue Apr 20, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@mukulashokjoshi

mukulashokjoshi commented Apr 20, 2016

Hi @almightycouch @katafrakt

First of all thanks for writing an ecto adapter for RethinkDB

I have currently integrated the ecto adapter in a phoenix web application. On executing a plain REST get all functionality it gives an error that "test.$TableName" does not exist, even though there is no "test" database configured in the application. Is this because the "test" database is configured in the config.exs which is part of rethinkdb_ecto or is there some other configuration which needs to be done?

Thanks & Regards

@ghost

This comment has been minimized.

Collaborator

ghost commented Apr 20, 2016

Hello @mukulashokjoshi.

Currently, passing a specific :db to the driver is not supported.
This means you have to set the :database config to "test".

config :myapp, My.Repo,
  adapter: RethinkDB.Ecto,
  database: "test",
  pool_size: 10

Once this is done, you should be able to run your migrations:

$ mix ecto.migrate

14:36:36.929 [info]  == Running MyApp.Repo.Migrations.CreateUser.change/0 forward

14:36:36.929 [info]  create table users

14:36:37.392 [info]  create index users_username_index

14:36:37.414 [info]  create index users_email_index

14:36:37.453 [info]  == Migrated in 5.2s

And use the the Repo to query the database:

iex(1)> Repo.all User
[]
@mukulashokjoshi

This comment has been minimized.

mukulashokjoshi commented Apr 20, 2016

Hi @almightycouch

Thanks for the reply

Does this mean that currently the Ecto Adapter cannot be used with a custom RethinkDB database with custom tables? I am assuming that when we configure the database that will be the database name existing in RethinkDB. Let me know if this is not correct.

Thanks & Regards

@mukulashokjoshi

This comment has been minimized.

mukulashokjoshi commented Apr 21, 2016

Hi @almightycouch

After creating the custom table in "test" database in RethinkDB, getting the below error on executing a REST POST call:

(Protocol.UndefinedError) protocol Enumerable not implemented for %Ecto.Query.Tagged{tag: nil, type: :map, value: nil}
        (elixir) lib/enum.ex:1: Enumerable.impl_for!/1
        (elixir) lib/enum.ex:116: Enumerable.reduce/3
        (elixir) lib/enum.ex:1477: Enum.reduce/3
        (elixir) lib/enum.ex:1092: Enum.map/2
        (rethinkdb) lib/rethinkdb/query/macros.ex:110: RethinkDB.Query.Macros.wrap/1
        (rethinkdb) lib/rethinkdb/query/macros.ex:111: anonymous fn/1 in RethinkDB.Query.Macros.wrap/1
        (elixir) lib/enum.ex:1092: anonymous fn/3 in Enum.map/2
        (stdlib) lists.erl:1262: :lists.foldl/3
        (elixir) lib/enum.ex:1092: Enum.map/2
        (rethinkdb) lib/rethinkdb/query/macros.ex:110: RethinkDB.Query.Macros.wrap/1
        (rethinkdb) lib/rethinkdb/query.ex:1325: RethinkDB.Query.insert/2
        (rethinkdb_ecto) lib/rethinkdb_ecto.ex:54: RethinkDB.Ecto.insert/6
        (ecto) lib/ecto/repo/schema.ex:297: Ecto.Repo.Schema.apply/5
        (ecto) lib/ecto/repo/schema.ex:81: anonymous fn/11 in Ecto.Repo.Schema.do_insert/4

Using UUID and Map in the model

Thanks & Regards

@ghost

This comment has been minimized.

Collaborator

ghost commented Apr 21, 2016

@mukulashokjoshi, has you might have seen, development on this repository has stopped quiet a bit for a while. More a proof of concept than anything else.

Ecto 2.0 brings a bunch of new features and changes. Basically i'm targeting compatibility with the new version (I started an ecto_2 branch a few days ago). You may have to wait some time before this gets more stable and ready to use.

@mukulashokjoshi

This comment has been minimized.

mukulashokjoshi commented Apr 21, 2016

Hi @almightycouch

Thanks for the clarification

Will recheck once you have something working based on Ecto 2.0

Thanks & Regards

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