Skip to content

Commit

Permalink
select: ignore wrong column name that starts with number in output_co…
Browse files Browse the repository at this point in the history
…lumns

The behavior change was unexpected. So we should revert the behavior
change.
  • Loading branch information
kou committed Oct 26, 2016
1 parent 4bc8da9 commit 88931a0
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/output.c
Expand Up @@ -2809,6 +2809,7 @@ is_output_columns_format_v1(grn_ctx *ctx,
{
const char *current;
const char *end;
grn_bool in_identifier = GRN_FALSE;

current = output_columns;
end = current + output_columns_len;
Expand All @@ -2822,18 +2823,29 @@ is_output_columns_format_v1(grn_ctx *ctx,

switch (current[0]) {
case ' ' :
case '.' :
case ',' :
in_identifier = GRN_FALSE;
break;
case '_' :
in_identifier = GRN_TRUE;
break;
case '.' :
case '-' :
case '#' :
case '@' :
if (!in_identifier) {
return GRN_FALSE;
}
break;
default :
if ('a' <= current[0] && current[0] <= 'z') {
in_identifier = GRN_TRUE;
break;
} else if ('A' <= current[0] && current[0] <= 'Z') {
in_identifier = GRN_TRUE;
break;
} else if ('0' <= current[0] && current[0] <= '9') {
in_identifier = GRN_TRUE;
break;
} else {
return GRN_FALSE;
Expand Down
@@ -0,0 +1,50 @@
table_create Sites TABLE_HASH_KEY ShortText
[[0,0.0,0.0],true]
column_create Sites uri COLUMN_SCALAR ShortText
[[0,0.0,0.0],true]
load --table Sites
[
["_key","uri"],
["groonga","http://groonga.org/"],
["razil","http://razil.jp/"]
]
[[0,0.0,0.0],2]
select Sites --output_columns '_id, _key, 0nonexistent, uri'
[
[
0,
0.0,
0.0
],
[
[
[
2
],
[
[
"_id",
"UInt32"
],
[
"_key",
"ShortText"
],
[
"uri",
"ShortText"
]
],
[
1,
"groonga",
"http://groonga.org/"
],
[
2,
"razil",
"http://razil.jp/"
]
]
]
]
@@ -0,0 +1,11 @@
table_create Sites TABLE_HASH_KEY ShortText
column_create Sites uri COLUMN_SCALAR ShortText

load --table Sites
[
["_key","uri"],
["groonga","http://groonga.org/"],
["razil","http://razil.jp/"]
]

select Sites --output_columns '_id, _key, 0nonexistent, uri'

0 comments on commit 88931a0

Please sign in to comment.