Lighter-swift / Lighter

Swift APIs for SQLite: Type-safe down to the schema. Very, very, fast. Dependency free.

Home Page:https://lighter-swift.github.io/documentation/lighter/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Directly parse SQL selects and generate VIEW like structs for them

helje5 opened this issue · comments

Instead of heaving to create a view like this:

CREATE VIEW fun_sum
  AS SELECT SUM(intCol) + SUM(doubleCol) AS lol FROM fun;

It would be nice if sqlite2swift could directly generate code for a SELECT expression, like:

-- Swift: fetchSums
SELECT SUM(intCol) + SUM(doubleCol) AS lol FROM fun; 

Similar to SQLDelight.

This has one big advantage, a binding could be specified at compile time, like:

-- Swift: fetchSums
SELECT SUM(intCol) + SUM(doubleCol) AS lol FROM fun WHERE year = $1; 

And added to the fetch function, like:

db.fun.fetchSums(1973)