COLLATE

abstract fun COLLATE(collate: Collate): Clause.Expression

Appends a COLLATE clause to the expression, specifying the collation sequence to use for string comparison.

A collation sequence defines the rules for how strings are compared and sorted, such as whether the comparison is case-sensitive, how it handles different character sets, and how it treats whitespace. SQLite provides three built-in collation functions:

  • Collate.BINARY: Compares strings byte by byte. It is case-sensitive.

  • Collate.NOCASE: Case-insensitive comparison. It considers 'a' and 'A' to be equal.

  • Collate.RTRIM: Similar to BINARY, but it ignores trailing whitespace.

This function can be chained to any expression that involves a string comparison, such as EQ, LIKE, GT, etc., to override the default collation of a column.

Example

// Find a user by email, forcing a case-sensitive comparison
// Generates: "email" = ? COLLATE BINARY
Users.email.EQ("user@example.com").COLLATE(Collate.BINARY)

Return

A new Expression with the COLLATE clause applied.

Author

MOHAMMAD AZIM ANSARI

Parameters

collate

The collation sequence to apply. This should be one of the predefined Collate enum values.

See also