anchor.diff:          S?SQL_SELECT.'WHERE'
       ).
   
  +duplicate_less_than_or_equal_to_filters_are_eliminated_test() ->
  +    DDL = get_ddl(
  +        "CREATE TABLE table1("
  +        "a TIMESTAMP NOT NULL, "
  +        "b SINT64 NOT NULL, "
  +        "PRIMARY KEY ((a),a))"),
  +    {ok, Q} = get_query(
  +        "SELECT * FROM table1 "
  +        "WHERE a = 5 AND b <= 8 AND b <= 8"),
  +    {ok, [S|_]} = compile(DDL, Q),
  +    ?assertPropsEqual(
  +        [{startkey,[{<<"a">>,timestamp,5}]},
  +         {endkey,  [{<<"a">>,timestamp,5}]},
  +         {filter, {'<=',{field,<<"b">>,sint64},{const,8}}},
  +         {end_inclusive,true}],
  +        S?SQL_SELECT.'WHERE'
  +    ).
  +
  +less_than_or_equal_to_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: is_inclusive_op('>')  -> false;
  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:     {Field, FieldType, _OldVal} = lists:keyfind(Field, 1, TupleList),
      lists:keyreplace(Field, 1, TupleList, {Field, FieldType, NewVal}).
  
  -record(filtercheck, {name,'=','>','>=','<','<='}).
  
  check_where_clause_is_possible(DDL, WhereProps) ->
      Filter1 = proplists:get_value(filter, WhereProps),
  