Resolve `unixepoch` SQL function as datetime

This commit is contained in:
Simon Binder 2022-06-16 18:28:20 +02:00
parent 5367072df5
commit c9bd7236c6
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
2 changed files with 5 additions and 1 deletions

View File

@ -523,7 +523,6 @@ class TypeResolver extends RecursiveVisitor<TypeExpectation, void> {
case 'datetime':
case 'julianday':
case 'strftime':
case 'unixepoch':
case 'char':
case 'hex':
case 'quote':
@ -588,6 +587,9 @@ class TypeResolver extends RecursiveVisitor<TypeExpectation, void> {
.._addRelation(CopyEncapsulating(e, params))
.._addRelation(HaveSameType(params));
return null;
case 'unixepoch':
return const ResolvedType(
type: BasicType.int, nullable: true, hint: IsDateTime());
}
final extensionHandler = _functionHandlerFor(e);

View File

@ -52,6 +52,8 @@ const Map<String, ResolvedType?> _types = {
"SELECT 'a' ->> ? = 'b'": ResolvedType(type: BasicType.text, nullable: false),
'SELECT MAX(id, ?) FROM demo': ResolvedType(type: BasicType.int),
'SELECT SUM(id = 2) = ? FROM demo': ResolvedType(type: BasicType.int),
"SELECT unixepoch('now') = ?":
ResolvedType(type: BasicType.int, nullable: true, hint: IsDateTime()),
};
SqlEngine _spawnEngine() {