Skip to content

Commit

Permalink
Add tests and update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
silviucpp committed Nov 8, 2022
1 parent 8b8a2fd commit a0e658e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
### Changelog:

##### v4.0.8

- Update cpp-driver to 2.16.2
- Add support to avoid creating tombstones while inserting data using prepared statements (https://github.com/silviucpp/erlcass/wiki/Null-bindings-on-prepared-statements-and-undesired-tombstone-creation).

##### v4.0.7

- Fix compilation on architectures where char is unsigned by default https://github.com/silviucpp/erlcass/issues/53
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ List of supported features:
- Asynchronous API
- Synchronous API
- Simple, Prepared, and Batch statements
- [Avoid undesired tombstone while null binding][10] (only on protocol 4 or newer).
- Paged queries
- Asynchronous I/O, parallel execution, and request pipelining
- Connection pooling
Expand Down Expand Up @@ -204,6 +205,7 @@ Also this is possible using `{Query, Options}` where options is a proplist with
- `serial_consistency_level` - This consistency can only be either `?CASS_CONSISTENCY_SERIAL` or
`?CASS_CONSISTENCY_LOCAL_SERIAL` and if not present, it defaults to `?CASS_CONSISTENCY_SERIAL`. This option will be
ignored for anything else that a conditional update/insert.
- `null_binding` - Boolean (by default `true`). Provides a way to disable the null values binding. [Binding null values][10] will create undesired tombstone in cassandra.

Example:

Expand Down Expand Up @@ -435,3 +437,4 @@ For mode details about bind by index and name please see: 'Run a prepared statem
[7]:https://github.com/lpgauth/marina
[8]:https://github.com/silviucpp/erlcass
[9]:https://github.com/silviucpp/erlcass/wiki/Todo-list
[10]:https://github.com/silviucpp/erlcass/wiki/Null-bindings-on-prepared-statements-and-undesired-tombstone-creation
2 changes: 1 addition & 1 deletion src/erlcass.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{description, "ErlCass - Erlang Cassandra Driver"},
{licenses, ["MIT"]},
{links,[{"Github","https://github.com/silviucpp/erlcass"}]},
{vsn, "4.0.7"},
{vsn, "4.0.8"},
{registered, []},
{applications, [kernel, stdlib, lager]},
{mod, {erlcass_app, []}},
Expand Down
26 changes: 22 additions & 4 deletions test/integrity_test_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ groups() -> [
date_time_testing,
get_metrics,
paged_query,
null_prepared_stm_binding,
drop_keyspace
]}
].
Expand Down Expand Up @@ -496,11 +497,28 @@ paged_query(_Config) ->
{ok, Stm} = erlcass:bind_prepared_statement(paged_query_prep),
PageSize = 3,
ok = erlcass:set_paging_size(Stm, PageSize),
{ok, _Columns, [[1],[2],[3]] = _Rows1, true = _HasMore1} = erlcass:execute_paged(Stm, paged_query_prep),
{ok, _Columns, [[4],[5],[6]] = _Rows2, true = _HasMore2} = erlcass:execute_paged(Stm, paged_query_prep),
{ok, _Columns, [[7],[8],[9]] = _Rows3, true = _HasMore3} = erlcass:execute_paged(Stm, paged_query_prep),
{ok, _Columns, [[10]] = _Rows4, false = _HasMore4} = erlcass:execute_paged(Stm, paged_query_prep),
{ok, _Columns1, [[1],[2],[3]] = _Rows1, true = _HasMore1} = erlcass:execute_paged(Stm, paged_query_prep),
{ok, _Columns2, [[4],[5],[6]] = _Rows2, true = _HasMore2} = erlcass:execute_paged(Stm, paged_query_prep),
{ok, _Columns3, [[7],[8],[9]] = _Rows3, true = _HasMore3} = erlcass:execute_paged(Stm, paged_query_prep),
{ok, _Columns4, [[10]] = _Rows4, false = _HasMore4} = erlcass:execute_paged(Stm, paged_query_prep),
ok.

null_prepared_stm_binding(_Config) ->
% none of the following inserts will create a tombstone while insert. To avoid tombstone while using prepared statements you can use one of:
% a) use bind by name and add into the binding params only the one with values (not null).
% b) while using binding by index use `undefined` atom for the values that are not set.
% c) when you prepare the statement use the option: `null_binding` as false.
ok = erlcass:query(<<"CREATE TABLE erlang_driver_test.null_prepared_stm_binding(key int PRIMARY KEY, name text, age int)">>),
ok = erlcass:add_prepare_statement(insert_unset_bind, <<"INSERT INTO erlang_driver_test.null_prepared_stm_binding (key, name, age) VALUES(?,?,?)">>),
ok = erlcass:add_prepare_statement(insert_unset_bind_2, {<<"INSERT INTO erlang_driver_test.null_prepared_stm_binding (key, name, age) VALUES(?,?,?)">>, [{null_binding, false}]}),
ok = erlcass:add_prepare_statement(select_unset_bind, <<"SELECT key, name, age FROM erlang_driver_test.null_prepared_stm_binding where key = ?">>),
ok = erlcass:execute(insert_unset_bind, ?BIND_BY_NAME, [{<<"key">>, 1}]),
ok = erlcass:execute(insert_unset_bind, ?BIND_BY_INDEX, [2, undefined, undefined]),
ok = erlcass:execute(insert_unset_bind_2, [3, null, null]),

{ok, _, [[1, null, null]]} = erlcass:execute(select_unset_bind, [1]),
{ok, _, [[2, null, null]]} = erlcass:execute(select_unset_bind, [2]),
{ok, _, [[3, null, null]]} = erlcass:execute(select_unset_bind, [3]).

drop_keyspace(_Config) ->
ok = erlcass:query(<<"DROP KEYSPACE erlang_driver_test">>).

0 comments on commit a0e658e

Please sign in to comment.