Skip to content

Commit

Permalink
handle the insert data bug of Virtuoso
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed May 1, 2024
1 parent 04e904d commit c96da3a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/sparql/client/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,12 @@ def expects_statements?

def to_s
graph = self.options[:graph] ? " GRAPH #{SPARQL::Client.serialize_uri(self.options[:graph])} " : ""
query_text = "INSERT #{!self.options[:graph] ? 'DATA' : ''} {"
query_text += graph + ' {' if self.options[:graph]

# use_insert_data option is because of Virtuous, remove when https://github.com/openlink/virtuoso-opensource/issues/126 closed
add_data = self.options[:use_insert_data].nil? || self.options[:use_insert_data] ? 'DATA' : ''

query_text = "INSERT #{add_data} {"
query_text += graph + '{' if self.options[:graph]
query_text += "\n"
query_text += RDF::NTriples::Writer.buffer { |writer| @data.each { |d| writer << d } }
query_text += '}' if self.options[:graph]
Expand Down
3 changes: 1 addition & 2 deletions spec/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@
it "supports the GRAPH modifier" do
[subject.insert_data(RDF::Graph.new, graph: 'http://example.org/'),
subject.insert_data(RDF::Graph.new).graph('http://example.org/')].each do |example|
# NCBO INSERT DATA expect
expect(example.to_s).to eq "INSERT { GRAPH <http://example.org/> {\n}}\n"
expect(example.to_s).to eq "INSERT DATA { GRAPH <http://example.org/> {\n}}\n"
end
end
end
Expand Down

0 comments on commit c96da3a

Please sign in to comment.