Navigation Menu

Skip to content

Commit

Permalink
Support '...' (single quoted string literal)
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 19, 2013
1 parent c99dd57 commit 380e834
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/expr.c
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
@@ -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"
]
]
]
]
@@ -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

0 comments on commit 380e834

Please sign in to comment.