DatabaseCollation

A Collation is a string comparison function used by SQLite.

  • The name of the collation

  • Creates a collation.

    let collation = DatabaseCollation("localized_standard") { (string1, string2) in
        return (string1 as NSString).localizedStandardCompare(string2)
    }
    db.add(collation: collation)
    try db.execute(sql: "CREATE TABLE file (name TEXT COLLATE localized_standard")
    

SQLite Collations

  • A collation, or SQL string comparison function, that compares strings according to the the Swift built-in == and <= operators.

    This collation is automatically added by GRDB to your database connections.

    You can use it when creating database tables:

    let collationName = DatabaseCollation.caseInsensitiveCompare.name
    dbQueue.execute(sql: """
        CREATE TABLE players (
          name TEXT COLLATE \(collationName)
        )
        """)
    
  • A collation, or SQL string comparison function, that compares strings according to the the Swift built-in caseInsensitiveCompare(_:) method.

    This collation is automatically added by GRDB to your database connections.

    You can use it when creating database tables:

    let collationName = DatabaseCollation.caseInsensitiveCompare.name
    dbQueue.execute(sql: """
        CREATE TABLE players (
          name TEXT COLLATE \(collationName)
        )
        """)
    
  • A collation, or SQL string comparison function, that compares strings according to the the Swift built-in localizedCaseInsensitiveCompare(_:) method.

    This collation is automatically added by GRDB to your database connections.

    You can use it when creating database tables:

    let collationName = DatabaseCollation.localizedCaseInsensitiveCompare.name
    dbQueue.execute(sql: """
        CREATE TABLE players (
          name TEXT COLLATE \(collationName)
        )
        """)
    
  • A collation, or SQL string comparison function, that compares strings according to the the Swift built-in localizedCompare(_:) method.

    This collation is automatically added by GRDB to your database connections.

    You can use it when creating database tables:

    let collationName = DatabaseCollation.localizedCompare.name
    dbQueue.execute(sql: """
        CREATE TABLE players (
          name TEXT COLLATE \(collationName)
        )
        """)
    
  • A collation, or SQL string comparison function, that compares strings according to the the Swift built-in localizedStandardCompare(_:) method.

    This collation is automatically added by GRDB to your database connections.

    You can use it when creating database tables:

    let collationName = DatabaseCollation.localizedStandardCompare.name
    dbQueue.execute(sql: """
        CREATE TABLE players (
          name TEXT COLLATE \(collationName)
        )
        """)