anchor.diff:          compile(DDL, Q)
       ).
   
  +less_than_on_column_in_local_key_is_added_to_endkey_test() ->
  +    DDL = get_ddl(
  +        "CREATE TABLE table1("
  +        "a TIMESTAMP NOT NULL, "
  +        "b SINT64 NOT NULL, "
  +        "PRIMARY KEY ((a),a,b))"),
  +    {ok, Q} = get_query(
  +        "SELECT * FROM table1 "
  +        "WHERE a = 5 AND b < 10"),
  +    {ok, [S|_]} = compile(DDL, Q),
  +    ?assertPropsEqual(
  +        [{startkey,[{<<"a">>,timestamp,5}]},
  +         {endkey,  [{<<"a">>,timestamp,5},{<<"b">>,sint64,10}]},
  +         {filter, {'<',{field,<<"b">>,sint64},{const,10}}},
  +         {end_inclusive,true}],
  +        S?SQL_SELECT.'WHERE'
  +    ).
  +
   -endif.
  
positive.code: 
  rewrite_end_key_with_filters([], _, _, EKey, EInc) ->
      {EKey, EInc};
  rewrite_end_key_with_filters([AddFieldName|Tail], ToKeyTypeFn, Filter, EKey, EInc) when is_binary(AddFieldName) ->
      case proplists:get_value(AddFieldName, Filter) of
          {'=',_,_} = F ->
              %% when an equality operator is found, we can put it on the key but
              %% cannot safely remove the filter
              EKeyElem = to_key_elem(ToKeyTypeFn, F),
              rewrite_end_key_with_filters(
                  Tail, ToKeyTypeFn, Filter, EKey++[EKeyElem], true);
          _ ->
              %% there is no filter for the next additional field so give up! The
              %% filters must be consecutive, we can't have a '_' inbetween
              %% values
              {EKey, EInc}
      end.
  
  is_inclusive_op('=')  -> true;
  is_inclusive_op('>')  -> false;
  is_inclusive_op('>=') -> true.
  
  %% Convert a filter to a start/end key element
  to_key_elem(ToKeyTypeFn, {_,{field,FieldName,_},{_,Val}}) ->
  
negative.code: rewrite_start_key_with_filters([AddFieldName|Tail], ToKeyTypeFn, Filter, SKey, SInc1) when is_binary(AddFieldName) ->
      case proplists:get_value(AddFieldName, Filter) of
          {Op,_,_} = F  when Op == '='; Op == '>'; Op == '>=' ->
              SKeyElem = to_key_elem(ToKeyTypeFn, F),
              %% if the quantum was inclusive, make sure we stay inclusive or
              %% the quantum boundary is modified later on
  