Kouhei Sutou
null+****@clear*****
Wed Jun 19 17:37:27 JST 2013
Kouhei Sutou 2013-06-19 17:37:27 +0900 (Wed, 19 Jun 2013) New Revision: 380e8346e1b2e1d278d4d66a1ad4676d36ca12d0 https://github.com/groonga/groonga/commit/380e8346e1b2e1d278d4d66a1ad4676d36ca12d0 Message: Support '...' (single quoted string literal) Added files: test/command/suite/select/output_columns/expression/literal/string/single_quote.expected test/command/suite/select/output_columns/expression/literal/string/single_quote.test Modified files: lib/expr.c Modified: lib/expr.c (+8 -3) =================================================================== --- lib/expr.c 2013-06-19 17:34:41 +0900 (aaa6b14) +++ lib/expr.c 2013-06-19 17:37:27 +0900 (4dadefa) @@ -5683,7 +5683,7 @@ exit : } static grn_rc -get_string(grn_ctx *ctx, efs_info *q) +get_string(grn_ctx *ctx, efs_info *q, char quote) { const char *s; unsigned int len; @@ -5692,7 +5692,7 @@ get_string(grn_ctx *ctx, efs_info *q) for (s = q->cur + 1; s < q->str_end; s += len) { if (!(len = grn_charlen(ctx, s, q->str_end))) { break; } if (len == 1) { - if (*s == GRN_QUERY_QUOTER) { + if (*s == quote) { s++; rc = GRN_SUCCESS; break; @@ -5933,7 +5933,12 @@ parse_script(grn_ctx *ctx, efs_info *q) grn_expr_append_op(ctx, q->e, GRN_OP_CJUMP, 0); break; case '"' : - if ((rc = get_string(ctx, q))) { goto exit; } + if ((rc = get_string(ctx, q, '"'))) { goto exit; } + PARSE(GRN_EXPR_TOKEN_STRING); + grn_expr_append_const(ctx, q->e, &q->buf, GRN_OP_PUSH, 1); + break; + case '\'' : + if ((rc = get_string(ctx, q, '\''))) { goto exit; } PARSE(GRN_EXPR_TOKEN_STRING); grn_expr_append_const(ctx, q->e, &q->buf, GRN_OP_PUSH, 1); break; Added: test/command/suite/select/output_columns/expression/literal/string/single_quote.expected (+38 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/output_columns/expression/literal/string/single_quote.expected 2013-06-19 17:37:27 +0900 (6bc8661) @@ -0,0 +1,38 @@ +table_create Entries TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Entries title COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +load --table Entries +[ +{"title": "groonga and MySQL"} +] +[[0,0.0,0.0],1] +select Entries --output_columns "_id, 'single quoted' + ' ' + 'string value'" --command_version 2 +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 1 + ], + [ + [ + "_id", + "UInt32" + ], + [ + "", + "null" + ] + ], + [ + 1, + "single quoted string value" + ] + ] + ] +] Added: test/command/suite/select/output_columns/expression/literal/string/single_quote.test (+11 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/output_columns/expression/literal/string/single_quote.test 2013-06-19 17:37:27 +0900 (4d1e13e) @@ -0,0 +1,11 @@ +table_create Entries TABLE_NO_KEY +column_create Entries title COLUMN_SCALAR ShortText + +load --table Entries +[ +{"title": "groonga and MySQL"} +] + +select Entries \ + --output_columns "_id, 'single quoted' + ' ' + 'string value'" \ + --command_version 2 -------------- next part -------------- HTML����������������������������...Download