Skip to content

Commit

Permalink
Disallow triple terms in subject position
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Oct 23, 2024
1 parent f5aa189 commit 5b9139c
Show file tree
Hide file tree
Showing 21 changed files with 201 additions and 333 deletions.
15 changes: 13 additions & 2 deletions lib/sparql.jison
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ BlankNode
//

TripleTermPattern
: '<<(' ReifiedTriplePatternObject Verb ReifiedTriplePatternObject ')>>' -> ensureReifiedTriples(nestedTriple($2, $3, $4))
: '<<(' TripleTermPatternSubject Verb ReifiedTriplePatternObject ')>>' -> ensureReifiedTriples(nestedTriple($2, $3, $4))
;

ReifiedTriplePattern
Expand All @@ -1643,7 +1643,7 @@ ReifiedTriplePattern
;

TripleTerm
: '<<(' ReifiedTripleObject IriOrA ReifiedTripleObject ')>>' -> ensureReifiedTriples(nestedTriple($2, $3, $4))
: '<<(' TripleTermSubject IriOrA ReifiedTripleObject ')>>' -> ensureReifiedTriples(nestedTriple($2, $3, $4))
;

ReifiedTriple
Expand All @@ -1664,6 +1664,17 @@ ReifiedTriplePatternObject
| TripleTermPattern
;

TripleTermPatternSubject
: Var
| iri
| BlankNode
;

TripleTermSubject
: iri
| BlankNode
;

Reifier
: iri
| BlankNode
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PREFIX : <http://example.com/ns#>

SELECT * {
VALUES ?x {
<<(:s :p :o )>>
<<( <<(:s :p :o )>> :q :z )>>
}
VALUES (?y ?z) { (<<(:s :p :o )>> 123 )
(123 <<(:s :p :o )>> ) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PREFIX : <http://example.com/ns#>

SELECT * {

<<(:x ?R :z )>> :p <<(:a :b ?C )>> .

<<( <<(:x ?R :z )>> :p <<(:a :b [] )>> )>>
:q
<<( <<([] ?R :z )>> :p <<(:a :b [] )>> )>> .
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PREFIX : <http://example.com/ns#>
SELECT * {
VALUES ?x {
<<(:s :p :o )>>
<<( <<(:s :p :o )>> :q :z )>>
<<( :x :q <<(:s :p :o )>> )>>
}
VALUES (?y ?z) { (<<(:s :p :o )>> 123 )
(123 <<(:s :p :o )>> ) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PREFIX : <http://example.com/ns#>

CONSTRUCT { <<(:s :p :o )>> :q :z }
CONSTRUCT { :s :q <<(:s :p :o )>> }
WHERE {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PREFIX : <http://example.com/ns#>

CONSTRUCT WHERE {
<<(?s ?p ?o )>> ?q ?z .
:s ?q <<(?s ?p :o )>> .
?a ?b <<(?s ?p ?o )>> .
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ PREFIX : <http://example.com/ns#>

SELECT * {

<<(:x ?R :z )>> :p <<(:a :b ?C )>> .

<<( <<(:x ?R :z )>> :p <<(:a :b [] )>> )>>
?s :p <<(:a :b ?C )>> .
?s
:q
<<( <<([] ?R :z )>> :p <<(:a :b [] )>> )>> .
<<( ?s1 :p <<(:a :b [] )>> )>> .
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PREFIX : <http://example.com/ns#>

SELECT * {
<<(?S :p :o )>> :r :z .
<<( <<(?S :p :o )>> :r :z )>> :q 1 .
:s :r <<(?S :p :o )>> .
:s :q <<( :s1 :r <<(?S :p :o )>> )>> .
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PREFIX : <http://example.com/ns#>

INSERT DATA {
<<( :a :b :c )>> :p :o .
:s :p <<( :a :b :c )>> .
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PREFIX : <http://example.com/ns#>

INSERT {
<<( :a :b :c )>> ?P :o2 {| ?Y ?Z |}
?S ?P <<( :a :b :c )>> {| ?Y ?Z |}
} WHERE {
<<( :a :b :c )>> ?P :o1 {| ?Y ?Z |}
:s ?P <<( :a :b :c )>> {| ?Y ?Z |}
}

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
PREFIX : <http://example.com/ns#>

INSERT {
<<( :a :b :c )>> ?P :o2 {| ?Y <<(:s1 :p1 ?Z)>> |}
:s ?P <<( :a :b :c )>> {| ?Y <<(:s1 :p1 ?Z)>> |}
} WHERE {
<<( :a :b :c )>> ?P :o1 {| ?Y <<(:s1 :p1 ?Z)>> |}
?s ?P <<( :a :b :c )>> {| ?Y <<(:s1 :p1 ?Z)>> |}
}

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{
"?x": {
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://example.com/ns#s"
Expand All @@ -34,8 +35,18 @@
{
"?x": {
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://example.com/ns#x"
},
"predicate": {
"termType": "NamedNode",
"value": "http://example.com/ns#q"
},
"object": {
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://example.com/ns#s"
Expand All @@ -53,14 +64,6 @@
"value": ""
}
},
"predicate": {
"termType": "NamedNode",
"value": "http://example.com/ns#q"
},
"object": {
"termType": "NamedNode",
"value": "http://example.com/ns#z"
},
"graph": {
"termType": "DefaultGraph",
"value": ""
Expand All @@ -75,6 +78,7 @@
{
"?y": {
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://example.com/ns#s"
Expand Down Expand Up @@ -114,6 +118,7 @@
},
"?z": {
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://example.com/ns#s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
"template": [
{
"subject": {
"termType": "NamedNode",
"value": "http://example.com/ns#s"
},
"predicate": {
"termType": "NamedNode",
"value": "http://example.com/ns#q"
},
"object": {
"termType": "Quad",
"value": "",
"subject": {
"termType": "NamedNode",
"value": "http://example.com/ns#s"
Expand All @@ -20,14 +29,6 @@
"termType": "DefaultGraph",
"value": ""
}
},
"predicate": {
"termType": "NamedNode",
"value": "http://example.com/ns#q"
},
"object": {
"termType": "NamedNode",
"value": "http://example.com/ns#z"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
"template": [
{
"subject": {
"termType": "NamedNode",
"value": "http://example.com/ns#s"
},
"predicate": {
"termType": "Variable",
"value": "q"
},
"object": {
"termType": "Quad",
"value": "",
"subject": {
"termType": "Variable",
"value": "s"
Expand All @@ -13,21 +22,13 @@
"value": "p"
},
"object": {
"termType": "Variable",
"value": "o"
"termType": "NamedNode",
"value": "http://example.com/ns#o"
},
"graph": {
"termType": "DefaultGraph",
"value": ""
}
},
"predicate": {
"termType": "Variable",
"value": "q"
},
"object": {
"termType": "Variable",
"value": "z"
}
},
{
Expand All @@ -41,6 +42,7 @@
},
"object": {
"termType": "Quad",
"value": "",
"subject": {
"termType": "Variable",
"value": "s"
Expand All @@ -66,7 +68,16 @@
"triples": [
{
"subject": {
"termType": "NamedNode",
"value": "http://example.com/ns#s"
},
"predicate": {
"termType": "Variable",
"value": "q"
},
"object": {
"termType": "Quad",
"value": "",
"subject": {
"termType": "Variable",
"value": "s"
Expand All @@ -76,21 +87,13 @@
"value": "p"
},
"object": {
"termType": "Variable",
"value": "o"
"termType": "NamedNode",
"value": "http://example.com/ns#o"
},
"graph": {
"termType": "DefaultGraph",
"value": ""
}
},
"predicate": {
"termType": "Variable",
"value": "q"
},
"object": {
"termType": "Variable",
"value": "z"
}
},
{
Expand All @@ -104,6 +107,7 @@
},
"object": {
"termType": "Quad",
"value": "",
"subject": {
"termType": "Variable",
"value": "s"
Expand Down
Loading

0 comments on commit 5b9139c

Please sign in to comment.