Case insensitive string comparison

2
Hi all, I use the xpath constraint: [Name = 'Test']. Name is of type String. Is this comparison executed case-insensitive? If not, how can i achieve a case-insensitive comparison?
asked
3 answers
6

This depends on the database being used.

By default with the '=' operator:

SQL Server: case-insensitive
PostgreSQL: case-sensitive
Oracle: case-sensitive
Built-in: case-insensitive

By default the 'contains()' function in XPath or the 'LIKE' operator in OQL searches always case-insensitive. (see )

answered
1

If you don't want the hassle of having to know which database type is in use, you could simply get the string you're comparing in lowercase by using the toLowerCase function. You can't use functions directly in an Xpath constraint itself, but you can make a temporary variable before the action you're using the Xpath in. Use the 'Create variable' action block, make a string and set the value to for example: toLowerCase($user/Name)

After this block you can use this string in the Xpath and compare it with 'test'. (You can do this with toUpperCase as well)

answered
-1

Case sensitivity of the equals ('=') operator depends on the database being used (thanks Jonathan!), but you can use contains consistently like so,

//Module.Entity[contains(Name,'test')]
answered