Navigation Menu

Skip to content

Commit

Permalink
search: care about nonexistent column reference case
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 10, 2014
1 parent e508f19 commit d023dc8
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/droonga/searcher.rb
Expand Up @@ -293,7 +293,7 @@ def parse_condition_hash(source, expression, condition)
end
begin
expression.parse(query, options)
rescue Groonga::SyntaxError
rescue Groonga::SyntaxError, Groonga::InvalidArgument
raise SyntaxError.new("query", query)
end
elsif condition["script"]
Expand Down
@@ -0,0 +1,37 @@
{
"datasets": {
"Droonga": {
"fact": "Memos",
"schema": {
"Memos": {
"type": "Hash",
"keyType": "ShortText",
"columns": {
"content": {
"type": "Scalar",
"valueType": "Text"
}
}
},
"Terms": {
"type": "PatriciaTrie",
"keyType": "ShortText",
"tokenizer": "TokenBigram",
"normalizer": "NormalizerAuto",
"columns": {
"memos_index": {
"type": "Index",
"valueType": "Memos",
"indexOptions": {
"sources": [
"content"
]
}
}
}
}
}
}
}
}

@@ -0,0 +1,48 @@
{
"inReplyTo": "request-id",
"statusCode": 400,
"type": "search.result",
"body": {
"name": "SyntaxError",
"message": "Syntax error: syntax:<query> input:<nonexistent:Droonga>",
"detail": {
"syntax": "query",
"input": "nonexistent:Droonga"
}
},
"errors": {
"sources0": {
"statusCode": 400,
"body": {
"name": "SyntaxError",
"message": "Syntax error: syntax:<query> input:<nonexistent:Droonga>",
"detail": {
"syntax": "query",
"input": "nonexistent:Droonga"
}
}
},
"sources1": {
"statusCode": 400,
"body": {
"name": "SyntaxError",
"message": "Syntax error: syntax:<query> input:<nonexistent:Droonga>",
"detail": {
"syntax": "query",
"input": "nonexistent:Droonga"
}
}
},
"sources2": {
"statusCode": 400,
"body": {
"name": "SyntaxError",
"message": "Syntax error: syntax:<query> input:<nonexistent:Droonga>",
"detail": {
"syntax": "query",
"input": "nonexistent:Droonga"
}
}
}
}
}
33 changes: 33 additions & 0 deletions test/command/suite/search/condition/query/nonexistent_column.test
@@ -0,0 +1,33 @@
# -*- js -*-
#@require-catalog-version 2
#@disable-logging
{
"type": "add",
"dataset": "Droonga",
"body": {
"table": "Memos",
"key": "droonga",
"values": {
"content": "Droonga is fun!"
}
}
}
#@enable-logging
{
"type": "search",
"dataset": "Droonga",
"body": {
"queries": {
"memos": {
"source": "Memos",
"condition": {
"matchTo": ["content"],
"query": "nonexistent:Droonga"
},
"output": {
"elements": ["count"]
}
}
}
}
}

0 comments on commit d023dc8

Please sign in to comment.