Closed jcoyne closed 9 years ago
I'm not certain how you want to handle this @gkellogg. Should we just strip statements with a nil object in preprocess_statement? Or should that raise an exception when you do an insert
?
It should already raise an error if the :validate option is set. Handling this in rdf.rb Writable#insert is probably of greater benefit. In general, I think bad data should just be dropped. Rdf-turtle can probably issue a warning. Validate mode is the way to ensure that such invalid data is identified.
Thanks for handling this. Just pushed out a patch release of rdf.rb, could push out a minor release for this.
@gkellogg it seems that fixing Writable would require changing this spec (https://github.com/ruby-rdf/rdf-spec/blob/develop/lib/rdf/spec/writable.rb#L65-L71) are you okay with that?
It should be okay to add an invalid statement, but statements containing nil elements are somewhat difference. This could be changed to something like the following:
it "inserts an invalid statement" do
skip("writability") unless subject.writable?
s = statement.clone
s.object = RDF::Literal("non-bool", datatype: RDF::XSD.boolean)
expect(s).not_to be_valid
subject << s
expect(subject.count).to eq 1
end
We might want to consider statements with nil members incomplete, in addition to being invalid. Note that a Query::Pattern subclasses Statement, and it's okay for Pattern elements to be nil.
Fixed in ruby-rdf/rdf/issues#226; incomplete statements always raise an error now, not just when validating.
Cool!