Skip to content

[BUG] ft:binary-field does not cast booleans #5193

@Bpolitycki

Description

@Bpolitycki

Describe the bug
Assuming I have a binary-field definition in my collection.xconf like this:

<!-- ... -->
  <field name="my-field" expression="true()" type="xs:boolean" binary="yes"/>
<!-- ... -->

and I am using ft:binary-field in the following way:

ft:binary-field($something, 'my-field', 'xs:boolean')

It does not cast the retrieved value into a xs:boolean.

Expected behavior
I would expect – as mentioned in the functions docs and the documentation on the index – that the value is casted or and error is raised. But instead it returns true as xs:string.

To Reproduce
See description above.

Context (please always complete the following information)

  • Build: eXist-6.2.0
  • Java: build 1.8.0_392-b08 (OpenJDK)
  • OS: Alpine-Linux (Docker)

Notes

I am not a Java person, but after a quick search in the eXist-source I would assume the problem is the missing case in bytesToAtomic. I think the addition of the following case might enable correct casting:

case Type.BOOLEAN:
                return BooleanValue.deserialize(ByteBuffer.wrap(field.bytes));

Otherwise it should be documented what values can be casted by calling ft:binary-field.

Metadata

Metadata

Assignees

Labels

Luceneissue is related to Lucene or its integrationbugissue confirmed as buginvestigateissues being looked at

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions