Fixed with semicolon space issue

This commit is contained in:
Mike Farah 2021-09-15 22:24:03 +10:00
parent 3339562aa2
commit 2292f0ffb4
4 changed files with 12 additions and 7 deletions

View File

@ -9,7 +9,7 @@ a:
```
then
```bash
yq eval 'with(.a.deeply.nested ; . = "newValue" | . style="single")' sample.yml
yq eval 'with(.a.deeply.nested; . = "newValue" | . style="single")' sample.yml
```
will output
```yaml
@ -28,7 +28,7 @@ a:
```
then
```bash
yq eval 'with(.a.deeply ; .nested = "newValue" | .other= "newThing")' sample.yml
yq eval 'with(.a.deeply; .nested = "newValue" | .other= "newThing")' sample.yml
```
will output
```yaml
@ -47,7 +47,7 @@ myArray:
```
then
```bash
yq eval 'with(.myArray[] ; .b = .a + " yum")' sample.yml
yq eval 'with(.myArray[]; .b = .a + " yum")' sample.yml
```
will output
```yaml

View File

@ -15,6 +15,11 @@ var pathTests = []struct {
expectedTokens []interface{}
expectedPostFix []interface{}
}{
{
"with(.a;.=3)",
append(make([]interface{}, 0), "WITH", "(", "a", "BLOCK", "SELF", "ASSIGN", "3 (int64)", ")"),
append(make([]interface{}, 0), "a", "SELF", "3 (int64)", "ASSIGN", "BLOCK", "WITH"),
},
{
"0x12",
append(make([]interface{}, 0), "18 (int64)"),

View File

@ -340,7 +340,7 @@ func initLexer() (*lex.Lexer, error) {
lexer.Add([]byte("( |\t|\n|\r)+"), skip)
lexer.Add([]byte(`\."[^ "]+"\??`), pathToken(true))
lexer.Add([]byte(`\.[^ \}\{\:\[\],\|\.\[\(\)=\n]+\??`), pathToken(false))
lexer.Add([]byte(`\.[^ ;\}\{\:\[\],\|\.\[\(\)=\n]+\??`), pathToken(false))
lexer.Add([]byte(`\.`), selfToken())
lexer.Add([]byte(`\|`), opToken(pipeOpType))

View File

@ -6,7 +6,7 @@ var withOperatorScenarios = []expressionScenario{
{
description: "Update and style",
document: `a: {deeply: {nested: value}}`,
expression: `with(.a.deeply.nested ; . = "newValue" | . style="single")`,
expression: `with(.a.deeply.nested; . = "newValue" | . style="single")`,
expected: []string{
"D0, P[], (doc)::a: {deeply: {nested: 'newValue'}}\n",
},
@ -14,7 +14,7 @@ var withOperatorScenarios = []expressionScenario{
{
description: "Update multiple deeply nested properties",
document: `a: {deeply: {nested: value, other: thing}}`,
expression: `with(.a.deeply ; .nested = "newValue" | .other= "newThing")`,
expression: `with(.a.deeply; .nested = "newValue" | .other= "newThing")`,
expected: []string{
"D0, P[], (doc)::a: {deeply: {nested: newValue, other: newThing}}\n",
},
@ -22,7 +22,7 @@ var withOperatorScenarios = []expressionScenario{
{
description: "Update array elements relatively",
document: `myArray: [{a: apple},{a: banana}]`,
expression: `with(.myArray[] ; .b = .a + " yum")`,
expression: `with(.myArray[]; .b = .a + " yum")`,
expected: []string{
"D0, P[], (doc)::myArray: [{a: apple, b: apple yum}, {a: banana, b: banana yum}]\n",
},