Lighter icon indicating copy to clipboard operation
Lighter copied to clipboard

SQLite Views loose type affinity w/ aggregates, workaround that

Open helje5 opened this issue 2 years ago • 1 comments

As soon as an aggregate function is used, SQLite seems to loose the type affinity of the expression, e.g.:

CREATE TABLE fun ( value INT );
CREATE VIEW fun_sum AS SELECT SUM(value) AS combined FROM fun;

Results in:

/// Column `combined ` (`ANY`), optional (default: `nil`).
public var combined : String?

Which isn't great.

Adding CASTs doesn't seem to help with that, the affinity is lost by the aggregate function. To fix that, we'd probably have to parse the SQL and follow the type-affinity in the expression AST. Possible but work.

helje5 avatar Aug 16 '22 16:08 helje5

Related to issue #2

helje5 avatar Aug 16 '22 16:08 helje5