cqex icon indicating copy to clipboard operation
cqex copied to clipboard

Using keyspace breaks CQEx

Open jvf opened this issue 7 years ago • 0 comments

There seems to be a bug in CQEx.Result.convert/2, the case of setting the keyspace seems not to be handled:

Calling

stmt = """
CREATE KEYSPACE foo 
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}
"""
Query.call(client, stmt)
Query.call(client, "USE foo")

fails with

** (FunctionClauseError) no function clause matching in CQEx.Result.convert/2

    The following arguments were given to CQEx.Result.convert/2:

        # 1
        {:set_keyspace, "foo"}

        # 2
        {#PID<0.474.0>, #Reference<0.2977995123.3760455683.197727>}

    Attempted function clauses (showing 3 out of 3):

        def convert(r, _client) when is_atom(:cql_result) and is_tuple(r) and tuple_size(r) > 0 and :erlang.element(1, r) == :cql_result
        def convert(q, client) when is_atom(:cql_schema_changed) and is_tuple(q) and tuple_size(q) > 0 and :erlang.element(1, q) == :cql_schema_changed
        def convert(:void, client)

    (cqex) lib/cqex/result.ex:35: CQEx.Result.convert/2
    (cqex) lib/cqex/query.ex:66: CQEx.Query.call/2

Calling

    {:ok, {:set_keyspace, "foo"}} = :cqerl.run_query(client, "USE foo")

directly works.

jvf avatar Sep 28 '17 09:09 jvf