Skip to content

Clarify handling of empty arguments in xpath function contains#10814

Open
pijuskri wants to merge 1 commit intomendix:developmentfrom
pijuskri:dat/contains-empty
Open

Clarify handling of empty arguments in xpath function contains#10814
pijuskri wants to merge 1 commit intomendix:developmentfrom
pijuskri:dat/contains-empty

Conversation

@pijuskri
Copy link
Contributor

No description provided.

@pijuskri
Copy link
Contributor Author

Needs team review

{{% alert color="info" %}}
In the case the `attribute` is empty or `NULL`, the function will always return `false`, independent of the value of `string_expression`.

In the case the `string_expression` is empty, it is treated as an empty string. The function is then equivalent to ```attribute != ''```.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct. The empty string still contains the empty string. It would be equivalent to attribute != empty.

`string_expression` specifies the value to test for being contained in the attribute. It can be a string literal or an expression that returns a string.

{{% alert color="info" %}}
In the case the `attribute` is empty or `NULL`, the function will always return `false`, independent of the value of `string_expression`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to be even more clear that this refers to an empty value, not the empty string.

@basdebakker
Copy link
Member

The same things hold for starts-with and ends-with. This should be clarified as well.


### expression

`string_expression` specifies the value to test for being contained in the attribute. It can be a string literal or an expression that returns a string.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only accept literals or parameters, not arbitrary expressions.


### attribute

`attribute` specifies the attribute to test in. Attribute must be of the **String** type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't have to be a simple attribute, it can also be a long path ending at an attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about mentioning that, but the entire xpath constraint documentation never explicitly mentions paths and always refers to attributes. I don't know if this distinction is necessary to highlight.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave this for @MarkvanMents to consider.

@basdebakker
Copy link
Member

Approved by datastorage team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants