Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Literal languages are lost on repeated #<< calls #245

Closed
no-reply opened this issue Aug 19, 2016 · 5 comments
Closed

Literal languages are lost on repeated #<< calls #245

no-reply opened this issue Aug 19, 2016 · 5 comments
Labels

Comments

@no-reply
Copy link
Member

We lose language values when setting using existing values. This affects #<<, and #set calls when a Relation is the argument.

require 'rdf/vocab'

class Book
  include ActiveTriples::RDFSource  
  property :title, predicate: RDF::Vocab::DC.title  
end  

book = Book.new

book.title << RDF::Literal("Moomin", language: :en)
book.title << RDF::Literal("Mummi",  language: :fi)

book.dump :ttl
# => "\n [ <http://purl.org/dc/terms/title> \"Moomin\",\n      \"Mummi\"@fi] .\n"⁠
@no-reply no-reply added the bug label Aug 19, 2016
@no-reply
Copy link
Member Author

This apparently affects every version, at least since 0.7.x.

no-reply pushed a commit that referenced this issue Aug 19, 2016
Fixes the bug in #245 causing literal languges to be lost when setting
values to an existing `Relation` (including self).
no-reply pushed a commit that referenced this issue Aug 19, 2016
Fixes the bug in #245 causing literal languges to be lost when setting
values to an existing `Relation` (including self).
@gkellogg
Copy link

gkellogg commented Aug 19, 2016

The vocabulary classes don't retain language. It keeps strings or symbols, which are interpreted according to the range of the property they use. Language has never been supported in the Vocabulary class definitions.

edit: presuming that these classes inherit from RDF::Vocabulary to manage properties and attributes.

@tpendragon
Copy link
Contributor

@gkellogg They don't, but that's good to know about RDF::Vocabulary.

@tpendragon
Copy link
Contributor

Some chatter in Hydra, summarized as such: This PR breaks identifiable in the following way - https://github.com/ActiveTriples/ActiveTriples/compare/literal_fix_breaking_spec#diff-2c44efc8662822e940a63660d6b0fcc2R171

no-reply pushed a commit that referenced this issue Aug 19, 2016
Reworks the default handling of `Relation` literal values:

  - Plain `xsd:String` literals are Ruby Strings;
  - `rdf:langString` literals are returned as `RDF::Literal` objects;
  - Known datatypes are cast to

When setting values from a Relation, always uses the `Literal`
value (through `Relation#objects`) to avoid losing data. URIs and blank
nods are still cast to their cached `RDFSource` versions.

Removes `literal: true` as a relation option.

Fixes the bug in #245 causing literal languges to be lost when setting
values to an existing `Relation` (including self).
@no-reply
Copy link
Member Author

Closed by #246.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants