mirror of https://github.com/AMT-Cheif/drift.git
Fix _encapsulate nullability for null literals
This commit is contained in:
parent
aa75cbaa19
commit
3bf91ed6c3
|
@ -160,7 +160,7 @@ class TypeGraph {
|
|||
if (previousType == elementType || elementType == BasicType.nullType) {
|
||||
return previous.withNullable(eitherNullable);
|
||||
}
|
||||
if (previousType == BasicType.nullType) return element;
|
||||
if (previousType == BasicType.nullType) return element.withNullable(true);
|
||||
|
||||
bool isIntOrNumeric(BasicType? type) {
|
||||
return type == BasicType.int || type == BasicType.real;
|
||||
|
|
|
@ -212,6 +212,21 @@ void main() {
|
|||
expect(type, const ResolvedType.bool());
|
||||
});
|
||||
|
||||
test('supports unions', () {
|
||||
void check(String sql) {
|
||||
final resolver = _obtainResolver(sql);
|
||||
final column = (resolver.session.context.root as CompoundSelectStatement)
|
||||
.resolvedColumns!
|
||||
.single;
|
||||
final type = resolver.session.typeOf(column)!;
|
||||
expect(type.type, BasicType.text);
|
||||
expect(type.nullable, isTrue);
|
||||
}
|
||||
|
||||
check("SELECT 'foo' AS r UNION ALL SELECT NULL AS r");
|
||||
check("SELECT NULL AS r UNION ALL SELECT 'foo' AS r");
|
||||
});
|
||||
|
||||
test('handles recursive CTEs', () {
|
||||
final type = _resolveResultColumn('''
|
||||
WITH RECURSIVE
|
||||
|
|
Loading…
Reference in New Issue