WHERE expressions: matrix cells + predicate_tail grammar fix (ADR-0026 step 6)
Adds tests/typing_surface/where_expression.rs — 9 matrix cells for the complex WHERE / show-data limit typing surface: operator candidates after an operand, AND / OR after a predicate, NOT, BETWEEN / IN bounds, and `show data` where / limit. Writing the cells surfaced a grammar bug. `predicate_tail`'s `[NOT] negatable` branch started with `Optional(not)`, and an Optional-first `Seq` always "commits" — so on an incomplete input the walker's `Choice` returned that branch's `Incomplete` early and discarded every sibling branch's expected set, dropping `is` and the comparison operators from completion after a column. Fixed by splitting it into explicit `NOT negatable` and bare `negatable` branches — no `predicate_tail` branch starts with an `Optional` now. The matched terminal sequence is unchanged, so `build_expr` is untouched. Docs: ADR-0026 gains an "As-built notes" section recording the option-1 builder realization, its two deviations from the §3 sketch, and the deferral of §7 diagnostic flagging to ADR-0027. requirements.md C5a -> [x] (steps 1-4) with the test baseline refreshed to 1079; CLAUDE.md's deferred list reconciled (C5a implemented; the QA1/QA2 note now points at ADR-0028).
This commit is contained in:
+47
@@ -0,0 +1,47 @@
|
||||
---
|
||||
source: tests/typing_surface/where_expression.rs
|
||||
description: "input=\"delete from Customers where id=1 \" cursor=33"
|
||||
expression: "& a"
|
||||
---
|
||||
Assessment {
|
||||
input: "delete from Customers where id=1 ",
|
||||
cursor: 33,
|
||||
state: Valid,
|
||||
hint: Some(
|
||||
Candidates {
|
||||
items: [
|
||||
Candidate {
|
||||
text: "and",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "or",
|
||||
kind: Keyword,
|
||||
},
|
||||
],
|
||||
selected: None,
|
||||
},
|
||||
),
|
||||
completion: Some(
|
||||
Completion {
|
||||
replaced_range: (
|
||||
33,
|
||||
33,
|
||||
),
|
||||
partial_prefix: "",
|
||||
candidates: [
|
||||
Candidate {
|
||||
text: "and",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "or",
|
||||
kind: Keyword,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
parse_result: Ok(
|
||||
"Delete",
|
||||
),
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
---
|
||||
source: tests/typing_surface/where_expression.rs
|
||||
description: "input=\"delete from Customers where not \" cursor=32"
|
||||
expression: "& a"
|
||||
---
|
||||
Assessment {
|
||||
input: "delete from Customers where not ",
|
||||
cursor: 32,
|
||||
state: IncompleteAtEof,
|
||||
hint: Some(
|
||||
Candidates {
|
||||
items: [
|
||||
Candidate {
|
||||
text: "not",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "null",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "true",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "false",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "(",
|
||||
kind: Punct,
|
||||
},
|
||||
Candidate {
|
||||
text: "Email",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "Name",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "id",
|
||||
kind: Identifier,
|
||||
},
|
||||
],
|
||||
selected: None,
|
||||
},
|
||||
),
|
||||
completion: Some(
|
||||
Completion {
|
||||
replaced_range: (
|
||||
32,
|
||||
32,
|
||||
),
|
||||
partial_prefix: "",
|
||||
candidates: [
|
||||
Candidate {
|
||||
text: "not",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "null",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "true",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "false",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "(",
|
||||
kind: Punct,
|
||||
},
|
||||
Candidate {
|
||||
text: "Email",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "Name",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "id",
|
||||
kind: Identifier,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
parse_result: Err(
|
||||
"Invalid(at_eof)",
|
||||
),
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
---
|
||||
source: tests/typing_surface/where_expression.rs
|
||||
description: "input=\"delete from Customers where Email \" cursor=34"
|
||||
expression: "& a"
|
||||
---
|
||||
Assessment {
|
||||
input: "delete from Customers where Email ",
|
||||
cursor: 34,
|
||||
state: IncompleteAtEof,
|
||||
hint: Some(
|
||||
Candidates {
|
||||
items: [
|
||||
Candidate {
|
||||
text: "is",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "not",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "like",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "between",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "in",
|
||||
kind: Keyword,
|
||||
},
|
||||
],
|
||||
selected: None,
|
||||
},
|
||||
),
|
||||
completion: Some(
|
||||
Completion {
|
||||
replaced_range: (
|
||||
34,
|
||||
34,
|
||||
),
|
||||
partial_prefix: "",
|
||||
candidates: [
|
||||
Candidate {
|
||||
text: "is",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "not",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "like",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "between",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "in",
|
||||
kind: Keyword,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
parse_result: Err(
|
||||
"Invalid(at_eof)",
|
||||
),
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
---
|
||||
source: tests/typing_surface/where_expression.rs
|
||||
description: "input=\"delete from Things where k between \" cursor=35"
|
||||
expression: "& a"
|
||||
---
|
||||
Assessment {
|
||||
input: "delete from Things where k between ",
|
||||
cursor: 35,
|
||||
state: IncompleteAtEof,
|
||||
hint: Some(
|
||||
Prose(
|
||||
"for `k`: Type an integer (e.g. 42, -7) or null",
|
||||
),
|
||||
),
|
||||
completion: Some(
|
||||
Completion {
|
||||
replaced_range: (
|
||||
35,
|
||||
35,
|
||||
),
|
||||
partial_prefix: "",
|
||||
candidates: [
|
||||
Candidate {
|
||||
text: "null",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "true",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "false",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "auto",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "b",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "d",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "data",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "dt",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "k",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "note",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "r",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "sid",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "ts",
|
||||
kind: Identifier,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
parse_result: Err(
|
||||
"Invalid(at_eof)",
|
||||
),
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
---
|
||||
source: tests/typing_surface/where_expression.rs
|
||||
description: "input=\"show data Customers where id=1 limit 10\" cursor=39"
|
||||
expression: "& a"
|
||||
---
|
||||
Assessment {
|
||||
input: "show data Customers where id=1 limit 10",
|
||||
cursor: 39,
|
||||
state: Valid,
|
||||
hint: Some(
|
||||
Prose(
|
||||
"Submit with Enter",
|
||||
),
|
||||
),
|
||||
completion: None,
|
||||
parse_result: Ok(
|
||||
"ShowData",
|
||||
),
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
---
|
||||
source: tests/typing_surface/where_expression.rs
|
||||
description: "input=\"delete from Things where k > 1 and t like 'a%' or k = 9\" cursor=55"
|
||||
expression: "& a"
|
||||
---
|
||||
Assessment {
|
||||
input: "delete from Things where k > 1 and t like 'a%' or k = 9",
|
||||
cursor: 55,
|
||||
state: Valid,
|
||||
hint: Some(
|
||||
Prose(
|
||||
"Submit with Enter",
|
||||
),
|
||||
),
|
||||
completion: None,
|
||||
parse_result: Ok(
|
||||
"Delete",
|
||||
),
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
---
|
||||
source: tests/typing_surface/where_expression.rs
|
||||
description: "input=\"delete from Things where k in (\" cursor=31"
|
||||
expression: "& a"
|
||||
---
|
||||
Assessment {
|
||||
input: "delete from Things where k in (",
|
||||
cursor: 31,
|
||||
state: IncompleteAtEof,
|
||||
hint: Some(
|
||||
Prose(
|
||||
"for `k`: Type an integer (e.g. 42, -7) or null",
|
||||
),
|
||||
),
|
||||
completion: Some(
|
||||
Completion {
|
||||
replaced_range: (
|
||||
31,
|
||||
31,
|
||||
),
|
||||
partial_prefix: "",
|
||||
candidates: [
|
||||
Candidate {
|
||||
text: "null",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "true",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "false",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "auto",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "b",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "d",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "data",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "dt",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "k",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "note",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "r",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "sid",
|
||||
kind: Identifier,
|
||||
},
|
||||
Candidate {
|
||||
text: "ts",
|
||||
kind: Identifier,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
parse_result: Err(
|
||||
"Invalid(at_eof)",
|
||||
),
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
---
|
||||
source: tests/typing_surface/where_expression.rs
|
||||
description: "input=\"show data Customers \" cursor=20"
|
||||
expression: "& a"
|
||||
---
|
||||
Assessment {
|
||||
input: "show data Customers ",
|
||||
cursor: 20,
|
||||
state: Valid,
|
||||
hint: Some(
|
||||
Candidates {
|
||||
items: [
|
||||
Candidate {
|
||||
text: "where",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "limit",
|
||||
kind: Keyword,
|
||||
},
|
||||
],
|
||||
selected: None,
|
||||
},
|
||||
),
|
||||
completion: Some(
|
||||
Completion {
|
||||
replaced_range: (
|
||||
20,
|
||||
20,
|
||||
),
|
||||
partial_prefix: "",
|
||||
candidates: [
|
||||
Candidate {
|
||||
text: "where",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "limit",
|
||||
kind: Keyword,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
parse_result: Ok(
|
||||
"ShowData",
|
||||
),
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
---
|
||||
source: tests/typing_surface/where_expression.rs
|
||||
description: "input=\"show data Customers where id=1 \" cursor=31"
|
||||
expression: "& a"
|
||||
---
|
||||
Assessment {
|
||||
input: "show data Customers where id=1 ",
|
||||
cursor: 31,
|
||||
state: Valid,
|
||||
hint: Some(
|
||||
Candidates {
|
||||
items: [
|
||||
Candidate {
|
||||
text: "and",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "or",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "limit",
|
||||
kind: Keyword,
|
||||
},
|
||||
],
|
||||
selected: None,
|
||||
},
|
||||
),
|
||||
completion: Some(
|
||||
Completion {
|
||||
replaced_range: (
|
||||
31,
|
||||
31,
|
||||
),
|
||||
partial_prefix: "",
|
||||
candidates: [
|
||||
Candidate {
|
||||
text: "and",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "or",
|
||||
kind: Keyword,
|
||||
},
|
||||
Candidate {
|
||||
text: "limit",
|
||||
kind: Keyword,
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
parse_result: Ok(
|
||||
"ShowData",
|
||||
),
|
||||
}
|
||||
Reference in New Issue
Block a user