Open aaj3f opened 8 months ago
The reason this is happening is that we no longer use sh:datatype
constraints to coerce the object at flake creation - we only pay attention to explicit @type
annotations or fall back to datatype inference - which in this case is an xsd:long
.
The reason we don't do that anymore is we don't have access to shacl shapes during the flake creation process. However, I have an idea that may allow us to cache that specific constraint in the db, at least for simple property paths - I'm not sure what the implication is for, say, inverse paths.
So the workaround in the meantime is to specify "schema:age" {"@type" "xsd:integer" "@value" 8}
if you want the object to be an integer.
Description
When setting
sh:datatype
on aPropertyShape
, certain numeric datatypes throw validation errors against what should be valid, coercible numbers. For example if transacting"schema:age": 8
, PropertyShapes withsh:datatype
ofxsd:integer
,xsd:int
, andxsd:float
throw invalid datatype errors (whereas, for example, ansh:datatype
ofxsd:long
does not throw an error).We have plenty of
coerce
tests indatatype_test.cljc
, so perhaps the issue has more to do with the representation of the JSON numeric value as its processed byserver
's HTTP API?Steps to Reproduce
Create Ledger (note that the example below uses
xsd:integer
but tests againstxsd:int
andxsd:float
produce the same behavior)Transaction of
schema:age
data onex:Yeti
Error result: