Susumu Yata
null+****@clear*****
Tue Oct 10 13:57:56 JST 2017
Susumu Yata 2017-10-10 13:57:56 +0900 (Tue, 10 Oct 2017) New Revision: d3f972b90694c6c116df82c879f5a7c18a7f9b45 https://github.com/groonga/groonga/commit/d3f972b90694c6c116df82c879f5a7c18a7f9b45 Message: NO_SYNTAX_ERROR: support queries starting with "~" GitHub: #767 Added files: test/command/suite/select/query_flags/query_no_syntax_error/leading_negative.expected test/command/suite/select/query_flags/query_no_syntax_error/leading_negative.test Modified files: lib/expr.c Modified: lib/expr.c (+11 -6) =================================================================== --- lib/expr.c 2017-10-08 10:44:58 +0900 (77fb99880) +++ lib/expr.c 2017-10-10 13:57:56 +0900 (515dbe068) @@ -7595,12 +7595,17 @@ parse_query(grn_ctx *ctx, efs_info *q) q->cur++; break; case GRN_QUERY_ADJ_NEG : - op->op = GRN_OP_ADJUST; - parse_query_accept_adjust(ctx, - q, - q->cur, 1, - GRN_EXPR_TOKEN_NEGATIVE, - -DEFAULT_WEIGHT); + if (first_token) { + parse_query_flush_pending_token(ctx, q); + parse_query_accept_string(ctx, q, q->cur, 1); + } else { + op->op = GRN_OP_ADJUST; + parse_query_accept_adjust(ctx, + q, + q->cur, 1, + GRN_EXPR_TOKEN_NEGATIVE, + -DEFAULT_WEIGHT); + } q->cur++; break; case GRN_QUERY_PARENL : Added: test/command/suite/select/query_flags/query_no_syntax_error/leading_negative.expected (+13 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/query_flags/query_no_syntax_error/leading_negative.expected 2017-10-10 13:57:56 +0900 (cd7323a86) @@ -0,0 +1,13 @@ +table_create Names TABLE_PAT_KEY ShortText +[[0,0.0,0.0],true] +table_create Tokens TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto +[[0,0.0,0.0],true] +column_create Tokens names_key COLUMN_INDEX|WITH_POSITION Names _key +[[0,0.0,0.0],true] +load --table Names +[ +{"_key": "name (x~y)"} +] +[[0,0.0,0.0],1] +select Names --match_columns "_key" --query "~y" --query_flags ALLOW_PRAGMA|ALLOW_COLUMN|QUERY_NO_SYNTAX_ERROR +[[0,0.0,0.0],[[[1],[["_id","UInt32"],["_key","ShortText"]],[1,"name (x~y)"]]]] Added: test/command/suite/select/query_flags/query_no_syntax_error/leading_negative.test (+16 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/query_flags/query_no_syntax_error/leading_negative.test 2017-10-10 13:57:56 +0900 (dd8a2b9de) @@ -0,0 +1,16 @@ +table_create Names TABLE_PAT_KEY ShortText + +table_create Tokens TABLE_PAT_KEY ShortText \ + --default_tokenizer TokenBigram \ + --normalizer NormalizerAuto +column_create Tokens names_key COLUMN_INDEX|WITH_POSITION Names _key + +load --table Names +[ +{"_key": "name (x~y)"} +] + +select Names \ + --match_columns "_key" \ + --query "~y" \ + --query_flags ALLOW_PRAGMA|ALLOW_COLUMN|QUERY_NO_SYNTAX_ERROR -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20171010/5e722bb4/attachment-0001.htm