From d762afbbaa617d1b94be73ec2a571b399cd3a069 Mon Sep 17 00:00:00 2001 From: Silviu Caragea Date: Mon, 29 Jun 2015 16:59:42 +0300 Subject: [PATCH] Fix binding for collections --- c_src/nif_cass_statement.cc | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/c_src/nif_cass_statement.cc b/c_src/nif_cass_statement.cc index 5abcba0..e876379 100644 --- a/c_src/nif_cass_statement.cc +++ b/c_src/nif_cass_statement.cc @@ -218,10 +218,18 @@ ERL_NIF_TERM bind_prepared_statement_params(ErlNifEnv* env, CassStatement* state size_t index = *it; const cass::ColumnDefinition def = result->metadata()->get(index); - SchemaColumn column(uint16_to_cass_value_type(def.type), - uint16_to_cass_value_type(def.collection_primary_type), - uint16_to_cass_value_type(def.collection_secondary_type)); + SchemaColumn column(uint16_to_cass_value_type(def.type)); + if(column.type == CASS_VALUE_TYPE_LIST || column.type == CASS_VALUE_TYPE_SET) + { + column.valueType = uint16_to_cass_value_type(def.collection_primary_type); + } + else if(column.type == CASS_VALUE_TYPE_MAP) + { + column.keyType = uint16_to_cass_value_type(def.collection_primary_type); + column.valueType = uint16_to_cass_value_type(def.collection_secondary_type); + } + ERL_NIF_TERM result = bind_param_by_index(env, statement, index, column, items[1]); if(!enif_is_identical(result, ATOMS.atomOk)) @@ -238,9 +246,17 @@ ERL_NIF_TERM bind_prepared_statement_params(ErlNifEnv* env, CassStatement* state const cass::ColumnDefinition def = result->metadata()->get(index); - SchemaColumn column(uint16_to_cass_value_type(def.type), - uint16_to_cass_value_type(def.collection_primary_type), - uint16_to_cass_value_type(def.collection_secondary_type)); + SchemaColumn column(uint16_to_cass_value_type(def.type)); + + if(column.type == CASS_VALUE_TYPE_LIST || column.type == CASS_VALUE_TYPE_SET) + { + column.valueType = uint16_to_cass_value_type(def.collection_primary_type); + } + else if(column.type == CASS_VALUE_TYPE_MAP) + { + column.keyType = uint16_to_cass_value_type(def.collection_primary_type); + column.valueType = uint16_to_cass_value_type(def.collection_secondary_type); + } ERL_NIF_TERM result = bind_param_by_index(env, statement, index, column, head);