Skip to content

Commit

Permalink
expr: support casting key in "!="
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Nov 19, 2018
1 parent b4b304e commit 3179939
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
20 changes: 17 additions & 3 deletions lib/expr.c
Expand Up @@ -3858,9 +3858,23 @@ grn_table_select_index_not_equal(grn_ctx *ctx,
if (GRN_OBJ_GET_DOMAIN(si->query) == DB_OBJ(domain)->id) {
tid = GRN_RECORD_VALUE(si->query);
} else {
tid = grn_table_get(ctx, domain,
GRN_BULK_HEAD(si->query),
GRN_BULK_VSIZE(si->query));
if (GRN_OBJ_GET_DOMAIN(si->query) == domain->header.domain) {
tid = grn_table_get(ctx, domain,
GRN_BULK_HEAD(si->query),
GRN_BULK_VSIZE(si->query));
} else {
grn_obj casted_query;
GRN_OBJ_INIT(&casted_query, GRN_BULK, 0, domain->header.domain);
if (grn_obj_cast(ctx, si->query, &casted_query, GRN_FALSE) ==
GRN_SUCCESS) {
tid = grn_table_get(ctx, domain,
GRN_BULK_HEAD(&casted_query),
GRN_BULK_VSIZE(&casted_query));
} else {
tid = GRN_ID_NIL;
}
GRN_OBJ_FIN(ctx, &casted_query);
}
}
if (tid == GRN_ID_NIL) {
processed = GRN_TRUE;
Expand Down
@@ -0,0 +1,17 @@
table_create Types TABLE_PAT_KEY ShortText
[[0,0.0,0.0],true]
table_create Entries TABLE_NO_KEY
[[0,0.0,0.0],true]
column_create Entries type COLUMN_SCALAR Types
[[0,0.0,0.0],true]
column_create Types entries COLUMN_INDEX Entries type
[[0,0.0,0.0],true]
load --table Entries
[
{"type": "10"},
{"type": "29"},
{"type": "fast"}
]
[[0,0.0,0.0],3]
select Entries --filter 'true && type != 29'
[[0,0.0,0.0],[[[2],[["_id","UInt32"],["type","Types"]],[1,"10"],[3,"fast"]]]]
@@ -0,0 +1,15 @@
table_create Types TABLE_PAT_KEY ShortText

table_create Entries TABLE_NO_KEY
column_create Entries type COLUMN_SCALAR Types

column_create Types entries COLUMN_INDEX Entries type

load --table Entries
[
{"type": "10"},
{"type": "29"},
{"type": "fast"}
]

select Entries --filter 'true && type != 29'

0 comments on commit 3179939

Please sign in to comment.