Skip to content

Commit 721b530

Browse files
committed
Fix bug in merge_node_map_graphs for @type.
1 parent 6449106 commit 721b530

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

lib/json/ld/flatten.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def merge_node_map_graphs(graph_map)
142142

143143
# Iterate over node properties
144144
node.each do |property, values|
145-
if property.start_with?('@')
145+
if property != '@type' && property.start_with?('@')
146146
# Copy keywords
147147
merged_node[property] = node[property].dup
148148
else

spec/frame_spec.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,6 +2305,50 @@
23052305
}
23062306
}),
23072307
processingMode: "json-ld-1.1"
2308+
},
2309+
"missing types": {
2310+
input: %({
2311+
"@context": {
2312+
"ex": "http://example.com#",
2313+
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
2314+
},
2315+
"@graph": [{
2316+
"@id": "ex:graph1",
2317+
"@graph": [{
2318+
"@id": "ex:entity1",
2319+
"@type": ["ex:Type1","ex:Type2"],
2320+
"ex:title": "some title",
2321+
"ex:multipleValues": "ex:One"
2322+
}]
2323+
}, {
2324+
"@id": "ex:graph2",
2325+
"@graph": [{
2326+
"@id": "ex:entity1",
2327+
"@type": "ex:Type3",
2328+
"ex:tags": "tag1 tag2",
2329+
"ex:multipleValues": ["ex:Two","ex:Three"]
2330+
}]
2331+
}]
2332+
}),
2333+
output: %({
2334+
"@context": {
2335+
"ex": "http://example.com#",
2336+
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
2337+
},
2338+
"@id": "ex:entity1",
2339+
"@type": ["ex:Type1", "ex:Type2", "ex:Type3"],
2340+
"ex:multipleValues": ["ex:One", "ex:Two","ex:Three"],
2341+
"ex:tags": "tag1 tag2",
2342+
"ex:title": "some title"
2343+
}),
2344+
frame: %({
2345+
"@context": {
2346+
"ex": "http://example.com#",
2347+
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
2348+
},
2349+
"@id": "ex:entity1"
2350+
}),
2351+
processingMode: "json-ld-1.1"
23082352
}
23092353
}.each do |title, params|
23102354
it title do

0 commit comments

Comments
 (0)