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

set_map doesn't work with DateTime in map #27

Open
optikfluffel opened this issue May 10, 2019 · 1 comment
Open

set_map doesn't work with DateTime in map #27

optikfluffel opened this issue May 10, 2019 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@optikfluffel
Copy link
Contributor

optikfluffel commented May 10, 2019

It seems set_map/2 doesn't work when there's a DateTime in the map. My best guess would be that the fact that DateTime is a map itself messes something up here.

Failing test for test/mutation_test.exs:

test "set_map/2 works with DateTime", %{conn: conn} do
  map_with_datetime_insert_mutation = %{
    name: "Alice",
    identifier: "alice_json",
    created_at: DateTime.utc_now()
  }

  {status, mutation_msg} = ExDgraph.set_map(conn, map_with_datetime_insert_mutation)
  assert status == :ok
  assert mutation_msg.context.aborted == false
end

Which results in:

  1) test set_map/2 works with DateTime (MutationTest)
     test/mutation_test.exs:121
     ** (Protocol.UndefinedError) protocol Enumerable not implemented for #DateTime<2019-05-10 21:37:46.845058Z>. This protocol is implemented for: DBConnection.Stream, DBConnection.PrepareStream, HashSet, Range, Map, Function, List, Stream, Date.Range, HashDict, GenEvent.Stream, MapSet, File.Stream, IO.Stream
     code: {status, mutation_msg} = ExDgraph.set_map(conn, map_with_datetime_insert_mutation)
     stacktrace:
       (elixir) /private/tmp/elixir-20190202-21222-1ilp2g0/elixir-1.8.1/lib/elixir/lib/enum.ex:1: Enumerable.impl_for!/1
       (elixir) /private/tmp/elixir-20190202-21222-1ilp2g0/elixir-1.8.1/lib/elixir/lib/enum.ex:141: Enumerable.reduce/3
       (elixir) lib/enum.ex:3015: Enum.reduce/3
       (ex_dgraph) lib/exdgraph/mutation.ex:129: anonymous fn/2 in ExDgraph.Mutation.insert_tmp_uids/1
       (stdlib) maps.erl:257: :maps.fold_1/3
       (ex_dgraph) lib/exdgraph/mutation.ex:28: ExDgraph.Mutation.set_map/2
       test/mutation_test.exs:128: (test)
@ospaarmann ospaarmann added the bug Something isn't working label Jul 31, 2019
@ospaarmann ospaarmann added this to the Version 0.3.0 milestone Aug 7, 2019
@ospaarmann
Copy link
Owner

@optikfluffel I am working on a larger release right now and will tackle this issue as part of it. Thank you for bringing it to my attention.

WIP here: https://github.com/ospaarmann/exdgraph/tree/update_to_db_connection_2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants