Skip to content

Commit

Permalink
Fixed issue in parser for directive location VARIABLE_DEFINITION. (#6553
Browse files Browse the repository at this point in the history
)
  • Loading branch information
michaelstaib authored Sep 25, 2023
1 parent f7eab8f commit ee46c0c
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ a SQL:

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE "d"."Bar" IS NOT NULL AND (@__p_0 = '' OR instr("d"."Bar", @__p_0) > 0)
WHERE "d"."Bar" IS NOT NULL AND instr("d"."Bar", @__p_0) > 0
---------------

b Result:
Expand All @@ -39,7 +39,7 @@ b SQL:

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE "d"."Bar" IS NOT NULL AND (@__p_0 = '' OR instr("d"."Bar", @__p_0) > 0)
WHERE "d"."Bar" IS NOT NULL AND instr("d"."Bar", @__p_0) > 0
---------------

null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ atest Result:

atest SQL:
---------------
.param set @__p_0 'atest'
.param set @__p_0_rewritten '%atest'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE "d"."Bar" IS NOT NULL AND (@__p_0 = '' OR substr("d"."Bar", -length(@__p_0)) = @__p_0 OR @__p_0 = '')
WHERE "d"."Bar" IS NOT NULL AND "d"."Bar" LIKE @__p_0_rewritten ESCAPE '\'
---------------

btest Result:
Expand All @@ -35,11 +35,11 @@ btest Result:

btest SQL:
---------------
.param set @__p_0 'btest'
.param set @__p_0_rewritten '%btest'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE "d"."Bar" IS NOT NULL AND (@__p_0 = '' OR substr("d"."Bar", -length(@__p_0)) = @__p_0 OR @__p_0 = '')
WHERE "d"."Bar" IS NOT NULL AND "d"."Bar" LIKE @__p_0_rewritten ESCAPE '\'
---------------

null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ a SQL:

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE "d"."Bar" IS NULL OR NOT (@__p_0 = '' OR instr("d"."Bar", @__p_0) > 0)
WHERE "d"."Bar" IS NULL OR NOT (instr("d"."Bar", @__p_0) > 0)
---------------

b Result:
Expand All @@ -45,7 +45,7 @@ b SQL:

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE "d"."Bar" IS NULL OR NOT (@__p_0 = '' OR instr("d"."Bar", @__p_0) > 0)
WHERE "d"."Bar" IS NULL OR NOT (instr("d"."Bar", @__p_0) > 0)
---------------

null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ atest Result:

atest SQL:
---------------
.param set @__p_0 'atest'
.param set @__p_0_rewritten '%atest'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE "d"."Bar" IS NULL OR (@__p_0 <> '' AND substr("d"."Bar", -length(@__p_0)) <> @__p_0 AND @__p_0 <> '')
WHERE "d"."Bar" IS NULL OR "d"."Bar" NOT LIKE @__p_0_rewritten ESCAPE '\'
---------------

btest Result:
Expand All @@ -41,11 +41,11 @@ btest Result:

btest SQL:
---------------
.param set @__p_0 'btest'
.param set @__p_0_rewritten '%btest'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE "d"."Bar" IS NULL OR (@__p_0 <> '' AND substr("d"."Bar", -length(@__p_0)) <> @__p_0 AND @__p_0 <> '')
WHERE "d"."Bar" IS NULL OR "d"."Bar" NOT LIKE @__p_0_rewritten ESCAPE '\'
---------------

null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ testa Result:

testa SQL:
---------------
.param set @__p_0 'testa'
.param set @__p_0_rewritten 'testa%'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE "d"."Bar" IS NULL OR (@__p_0 <> '' AND ("d"."Bar" NOT LIKE @__p_0 || '%' OR substr("d"."Bar", 1, length(@__p_0)) <> @__p_0) AND @__p_0 <> '')
WHERE "d"."Bar" IS NULL OR "d"."Bar" NOT LIKE @__p_0_rewritten ESCAPE '\'
---------------

testb Result:
Expand All @@ -41,11 +41,11 @@ testb Result:

testb SQL:
---------------
.param set @__p_0 'testb'
.param set @__p_0_rewritten 'testb%'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE "d"."Bar" IS NULL OR (@__p_0 <> '' AND ("d"."Bar" NOT LIKE @__p_0 || '%' OR substr("d"."Bar", 1, length(@__p_0)) <> @__p_0) AND @__p_0 <> '')
WHERE "d"."Bar" IS NULL OR "d"."Bar" NOT LIKE @__p_0_rewritten ESCAPE '\'
---------------

null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ testa Result:

testa SQL:
---------------
.param set @__p_0 'testa'
.param set @__p_0_rewritten 'testa%'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE "d"."Bar" IS NOT NULL AND (@__p_0 = '' OR ("d"."Bar" LIKE @__p_0 || '%' AND substr("d"."Bar", 1, length(@__p_0)) = @__p_0) OR @__p_0 = '')
WHERE "d"."Bar" IS NOT NULL AND "d"."Bar" LIKE @__p_0_rewritten ESCAPE '\'
---------------

testb Result:
Expand All @@ -35,11 +35,11 @@ testb Result:

testb SQL:
---------------
.param set @__p_0 'testb'
.param set @__p_0_rewritten 'testb%'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE "d"."Bar" IS NOT NULL AND (@__p_0 = '' OR ("d"."Bar" LIKE @__p_0 || '%' AND substr("d"."Bar", 1, length(@__p_0)) = @__p_0) OR @__p_0 = '')
WHERE "d"."Bar" IS NOT NULL AND "d"."Bar" LIKE @__p_0_rewritten ESCAPE '\'
---------------

null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ a SQL:

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE @__p_0 = '' OR instr("d"."Bar", @__p_0) > 0
WHERE instr("d"."Bar", @__p_0) > 0
---------------

b Result:
Expand All @@ -39,7 +39,7 @@ b SQL:

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE @__p_0 = '' OR instr("d"."Bar", @__p_0) > 0
WHERE instr("d"."Bar", @__p_0) > 0
---------------

null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ atest Result:

atest SQL:
---------------
.param set @__p_0 'atest'
.param set @__p_0_rewritten '%atest'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE @__p_0 = '' OR substr("d"."Bar", -length(@__p_0)) = @__p_0 OR @__p_0 = ''
WHERE "d"."Bar" LIKE @__p_0_rewritten ESCAPE '\'
---------------

btest Result:
Expand All @@ -35,11 +35,11 @@ btest Result:

btest SQL:
---------------
.param set @__p_0 'btest'
.param set @__p_0_rewritten '%btest'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE @__p_0 = '' OR substr("d"."Bar", -length(@__p_0)) = @__p_0 OR @__p_0 = ''
WHERE "d"."Bar" LIKE @__p_0_rewritten ESCAPE '\'
---------------

null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ a SQL:

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE NOT (@__p_0 = '' OR instr("d"."Bar", @__p_0) > 0)
WHERE NOT (instr("d"."Bar", @__p_0) > 0)
---------------

b Result:
Expand All @@ -39,7 +39,7 @@ b SQL:

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE NOT (@__p_0 = '' OR instr("d"."Bar", @__p_0) > 0)
WHERE NOT (instr("d"."Bar", @__p_0) > 0)
---------------

null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ atest Result:

atest SQL:
---------------
.param set @__p_0 'atest'
.param set @__p_0_rewritten '%atest'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE @__p_0 <> '' AND substr("d"."Bar", -length(@__p_0)) <> @__p_0 AND @__p_0 <> ''
WHERE "d"."Bar" NOT LIKE @__p_0_rewritten ESCAPE '\'
---------------

btest Result:
Expand All @@ -35,11 +35,11 @@ btest Result:

btest SQL:
---------------
.param set @__p_0 'btest'
.param set @__p_0_rewritten '%btest'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE @__p_0 <> '' AND substr("d"."Bar", -length(@__p_0)) <> @__p_0 AND @__p_0 <> ''
WHERE "d"."Bar" NOT LIKE @__p_0_rewritten ESCAPE '\'
---------------

null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ testa Result:

testa SQL:
---------------
.param set @__p_0 'testa'
.param set @__p_0_rewritten 'testa%'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE @__p_0 <> '' AND ("d"."Bar" NOT LIKE @__p_0 || '%' OR substr("d"."Bar", 1, length(@__p_0)) <> @__p_0) AND @__p_0 <> ''
WHERE "d"."Bar" NOT LIKE @__p_0_rewritten ESCAPE '\'
---------------

testb Result:
Expand All @@ -35,11 +35,11 @@ testb Result:

testb SQL:
---------------
.param set @__p_0 'testb'
.param set @__p_0_rewritten 'testb%'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE @__p_0 <> '' AND ("d"."Bar" NOT LIKE @__p_0 || '%' OR substr("d"."Bar", 1, length(@__p_0)) <> @__p_0) AND @__p_0 <> ''
WHERE "d"."Bar" NOT LIKE @__p_0_rewritten ESCAPE '\'
---------------

null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ testa Result:

testa SQL:
---------------
.param set @__p_0 'testa'
.param set @__p_0_rewritten 'testa%'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE @__p_0 = '' OR ("d"."Bar" LIKE @__p_0 || '%' AND substr("d"."Bar", 1, length(@__p_0)) = @__p_0) OR @__p_0 = ''
WHERE "d"."Bar" LIKE @__p_0_rewritten ESCAPE '\'
---------------

testb Result:
Expand All @@ -35,11 +35,11 @@ testb Result:

testb SQL:
---------------
.param set @__p_0 'testb'
.param set @__p_0_rewritten 'testb%'

SELECT "d"."Id", "d"."Bar"
FROM "Data" AS "d"
WHERE @__p_0 = '' OR ("d"."Bar" LIKE @__p_0 || '%' AND substr("d"."Bar", 1, length(@__p_0)) = @__p_0) OR @__p_0 = ''
WHERE "d"."Bar" LIKE @__p_0_rewritten ESCAPE '\'
---------------

null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ input FooInput {
enum Foo {
"Bar enum value"
BAR
@source(subgraph: "A")
@source(subgraph: "B")
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ private static IEnumerable<DirectiveLocation> GetAll()
yield return FragmentDefinition;
yield return FragmentSpread;
yield return InlineFragment;
yield return VariableDefinition;
yield return Schema;
yield return Scalar;
yield return Object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,17 @@ public void OneGraph_Schema()
// assert
document.ToString().MatchSnapshot();
}

[Fact]
public void Parse_Directive_With_VariableDefinition()
{
// arrange
const string sourceText = "directive @foo(a: String) on VARIABLE_DEFINITION";

// act
var document = Utf8GraphQLParser.Parse(sourceText);

// assert
document.ToString().MatchSnapshot();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
directive @foo(a: String) on VARIABLE_DEFINITION

0 comments on commit ee46c0c

Please sign in to comment.