FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date.

For more details, see the v4 EOL announcement and migration guide. Contact support@fauna.com with any questions.

Casefold

This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics.

Casefold( value, [ normalizer ] )
casefold( value, [ normalizer ] )
Casefold( value, [ normalizer ] )
Casefold( value, [ normalizer ] )
Casefold( value, [ normalizer ] )

Description

The Casefold function returns a normalized string. When strings are transformed into their normalized forms, canonical-equivalent strings have precisely the same binary representation. Then, a binary comparison function such as equals can compare two strings for case-insensitive matching.

The Unicode Standard provides well-defined normalization forms (see Section 5.18, Case Mappings).

By default, Fauna uses NKFCCaseFold as recommended by the W3C, but provides NFKCCaseFold, NFC, NFD, NFKC, NFKD.

Parameters

Parameter Type Definition and Requirements

value

String

A string to normalize.

normalizer

String

Optional - The name of the normalizer method to use. Must be one of "NFKCCaseFold", "NFC", "NFD", "NFKC", or "NFKD". Defaults to "NFKCCaseFold".

Returns

A string value.

Examples

The following query converts the string "Hen Wen" to "hen wen" to support case-insensitive matching:

client.query(
  q.Casefold('Hen Wen')
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
hen wen
result = client.query(
    q.casefold("Hen Wen")
)
print(result)
hen wen
result, err := client.Query(
	f.Casefold("Hen Wen"))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
hen wen
try
{
    Value result = await client.Query(
        Casefold("Hen Wen")
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
StringV(hen wen)
Casefold('Hen Wen')
'hen wen'
Query metrics:
  •    bytesIn:  22

  •   bytesOut:  22

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 3ms

  •    retries:   0

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!