Datatypes in SPARQL UPDATE

Hi

I just started playing with Stardog and noticed that datatypes are not preserved or am I missing something? Below are the queries to reproduce

PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

INSERT DATA
{ 
  <http://example/book2> dc:title "A new book" .
  <http://example/book2> <id:idInteger> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
  <http://example/book2> <id:idPositiveInteger> "2"^^<http://www.w3.org/2001/XMLSchema#positiveInteger> .
  <http://example/book2> <id:idInt> "3"^^<http://www.w3.org/2001/XMLSchema#int> .

  <http://example/book2> <id:idInteger> "11"^^xsd:integer .
  <http://example/book2> <id:idPositiveInteger> "12"^^xsd:positiveInteger .
  <http://example/book2> <id:idInt> "13"^^xsd:int .
}

Read query
SELECT * WHERE { ?s ?p ?o . bind(datatype(?o)as ?d)}

Result

{
  "head": {
    "vars": [
      "s",
      "p",
      "o",
      "d"
    ]
  },
  "results": {
    "bindings": [
      {
        "p": {
          "type": "uri",
          "value": "http://purl.org/dc/elements/1.1/title"
        },
        "s": {
          "type": "uri",
          "value": "http://example/book2"
        },
        "d": {
          "type": "uri",
          "value": "http://www.w3.org/2001/XMLSchema#string"
        },
        "o": {
          "type": "literal",
          "value": "A new book"
        }
      },
      {
        "p": {
          "type": "uri",
          "value": "id:idInteger"
        },
        "s": {
          "type": "uri",
          "value": "http://example/book2"
        },
        "d": {
          "type": "uri",
          "value": "http://www.w3.org/2001/XMLSchema#integer"
        },
        "o": {
          "datatype": "http://www.w3.org/2001/XMLSchema#integer",
          "type": "literal",
          "value": "1"
        }
      },
      {
        "p": {
          "type": "uri",
          "value": "id:idPositiveInteger"
        },
        "s": {
          "type": "uri",
          "value": "http://example/book2"
        },
        "d": {
          "type": "uri",
          "value": "http://www.w3.org/2001/XMLSchema#integer"
        },
        "o": {
          "datatype": "http://www.w3.org/2001/XMLSchema#integer",
          "type": "literal",
          "value": "2"
        }
      },
      {
        "p": {
          "type": "uri",
          "value": "id:idInt"
        },
        "s": {
          "type": "uri",
          "value": "http://example/book2"
        },
        "d": {
          "type": "uri",
          "value": "http://www.w3.org/2001/XMLSchema#integer"
        },
        "o": {
          "datatype": "http://www.w3.org/2001/XMLSchema#integer",
          "type": "literal",
          "value": "3"
        }
      },
      {
        "p": {
          "type": "uri",
          "value": "id:idInteger"
        },
        "s": {
          "type": "uri",
          "value": "http://example/book2"
        },
        "d": {
          "type": "uri",
          "value": "http://www.w3.org/2001/XMLSchema#integer"
        },
        "o": {
          "datatype": "http://www.w3.org/2001/XMLSchema#integer",
          "type": "literal",
          "value": "11"
        }
      },
      {
        "p": {
          "type": "uri",
          "value": "id:idPositiveInteger"
        },
        "s": {
          "type": "uri",
          "value": "http://example/book2"
        },
        "d": {
          "type": "uri",
          "value": "http://www.w3.org/2001/XMLSchema#integer"
        },
        "o": {
          "datatype": "http://www.w3.org/2001/XMLSchema#integer",
          "type": "literal",
          "value": "12"
        }
      },
      {
        "p": {
          "type": "uri",
          "value": "id:idInt"
        },
        "s": {
          "type": "uri",
          "value": "http://example/book2"
        },
        "d": {
          "type": "uri",
          "value": "http://www.w3.org/2001/XMLSchema#integer"
        },
        "o": {
          "datatype": "http://www.w3.org/2001/XMLSchema#integer",
          "type": "literal",
          "value": "13"
        }
      }
    ]
  }
}

Hi,

There is actually another thread in which we detail what's happening here: Datatype handling

The short version is Stardog canonicalizes literals by default to improve query and loading performance. If you require literals to be stored exactly as specified, you can set index.literals.canonical=false when creating your database.

Nice one. Thanks, make sense.