Lighter icon indicating copy to clipboard operation
Lighter copied to clipboard

Directly parse SQL selects and generate VIEW like structs for them

Open helje5 opened this issue 2 years ago • 0 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)

helje5 avatar Aug 16 '22 16:08 helje5