groue / GRDB.swift

A toolkit for SQLite databases, with a focus on application development
MIT License
6.61k stars 677 forks source link

Support for the CAST SQLite function #1515

Closed groue closed 3 months ago

groue commented 3 months ago

This pull request adds built-in support for the SQLite CAST function. The cast(_:as:) Swift function accepts expressions, and association aggregates.

cast(Column("wins"), as: .real)
cast(Player.games.count, as: .real)

Fixes #1514

leotumwattana commented 3 months ago

There is a more complex case where using cast will not work.

Please see: https://github.com/groue/GRDB.swift/issues/1514#issuecomment-2016600794