mirror of https://github.com/AMT-Cheif/drift.git
sqlparser: Support new SQL functions
This commit is contained in:
parent
559cf986a1
commit
222dc3063e
|
@ -3,6 +3,7 @@
|
|||
- Treat the result of `sum()` as nullable when inferring types.
|
||||
- Support features added in sqlite 3.44:
|
||||
- `ORDER BY` clauses as part of aggregate functions.
|
||||
- Support `concat`, `concat_ws` and `string_agg`.
|
||||
|
||||
## 0.32.0
|
||||
|
||||
|
|
|
@ -278,6 +278,7 @@ class LintingVisitor extends RecursiveVisitor<void, void> {
|
|||
'format' || 'unixepoch' => SqliteVersion.v3_38,
|
||||
'unhex' => SqliteVersion.v3_41,
|
||||
'timediff' || 'octet_length' => SqliteVersion.v3_43,
|
||||
'concat' || 'concat_ws' || 'string_agg' => SqliteVersion.v3_44,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
|
|
|
@ -573,7 +573,16 @@ class TypeResolver extends RecursiveVisitor<TypeExpectation, void> {
|
|||
case 'upper':
|
||||
nullableIfChildIs();
|
||||
return _textType.withoutNullabilityInfo;
|
||||
case 'concat':
|
||||
return _textType;
|
||||
case 'concat_ws':
|
||||
// null if the first argument is null
|
||||
if (params.isNotEmpty) {
|
||||
session._addRelation(NullableIfSomeOtherIs(e, [params.first]));
|
||||
}
|
||||
return _textType.withoutNullabilityInfo;
|
||||
case 'group_concat':
|
||||
case 'string_agg':
|
||||
return _textType.withNullable(true);
|
||||
case 'date':
|
||||
case 'time':
|
||||
|
|
|
@ -66,6 +66,12 @@ const Map<String, ResolvedType?> _types = {
|
|||
"SELECT unhex('ab') = ?": ResolvedType(type: BasicType.blob, nullable: true),
|
||||
'SELECT unhex(?)': ResolvedType(type: BasicType.text),
|
||||
'SELECT 1 GROUP BY 1 HAVING ? ': ResolvedType.bool(),
|
||||
"SELECT concat(1, NULL, 2) = ?":
|
||||
ResolvedType(type: BasicType.text, nullable: false),
|
||||
"SELECT concat_ws(',', 1, 2) = ?":
|
||||
ResolvedType(type: BasicType.text, nullable: false),
|
||||
"SELECT concat_ws(NULL, 1, 2) = ?":
|
||||
ResolvedType(type: BasicType.text, nullable: true),
|
||||
};
|
||||
|
||||
SqlEngine _spawnEngine() {
|
||||
|
|
Loading…
Reference in New Issue