google-code-export / sqljet

Automatically exported from code.google.com/p/sqljet
0 stars 1 forks source link

Non-intuitive behavior ISqlJetTable.scope() when upper bound is null #149

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Create index on table, e.g.

db.createTable("CREATE TABLE record (a INTEGER NOT NULL, b INTEGER NOT NULL)");
db.createIndex("CREATE INDEX record_idx ON record (a, b)");

2. populate table with records.

3. access using ISqlJetTable.scope() with null upper bound, e.g.

SqlJetTable table = db.getTable("record");
ISqlJetCursor cursor = table.scope("record_idx", new Object[] { 5 }, new 
Object[] { null });

What is the expected output? What do you see instead?

Expect ascending access to those records with field >= 5, but instead get 
descending access to those records with field <= 5.

What version of the product are you using? On what operating system?

1.0.3.b914, Linux.

Please provide any additional information below.

This behavior is both unintuitive and doesn't seem to allow for any way to ask 
for records with an open upper bound.

Original issue reported on code.google.com by cdemarc...@gmail.com on 16 Mar 2011 at 9:58

GoogleCodeExporter commented 9 years ago

Original comment by sergey.s...@gmail.com on 17 Mar 2011 at 9:17

GoogleCodeExporter commented 9 years ago
This behaviour is expected. Object[] {null} is a single-object array, which is 
treated as Object[] {minimalValue} in this context. In order to specify 
unbounded scope, you should pass null value for an array: 

cursor = table.scope("record_idx", new Object[] {5}, null);

This will produce desired result. See also new test in trunk 
(ScopeWithNullBoundTest) which demonstrates how scopes are processed in case on 
of the bounds is null. When both bounds are null, scope is all-inclusive.

Original comment by kit...@gmail.com on 22 Mar 2011 at 5:07