mirror of https://github.com/AMT-Cheif/drift.git
Make rowid aliases non-nullable (#1128)
This commit is contained in:
parent
0692182829
commit
9b6b5d1b69
|
@ -2,6 +2,7 @@
|
|||
|
||||
- New analysis checks for `RETURNING`: Disallow `table.*` syntax and aggregate expressions
|
||||
- Fix resolving columns when `RETURNING` is used in an `UPDATE FROM` statement
|
||||
- Fix aliases to rowid being reported as nullable
|
||||
|
||||
## 0.15.0
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ class Table extends NamedResultSet with HasMetaMixin implements HumanReadable {
|
|||
|
||||
if (_rowIdColumn == null && column.isAliasForRowId()) {
|
||||
_rowIdColumn = column;
|
||||
// By design, the rowid is non-nullable, even if there isn't a NOT NULL
|
||||
// constraint set on the column definition.
|
||||
column._type = const ResolvedType(type: BasicType.int, nullable: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,4 +127,14 @@ void main() {
|
|||
final table = engine.schemaReader.read(stmt as CreateTableStatement);
|
||||
expect(table.resolvedColumns.single.type.type, BasicType.blob);
|
||||
});
|
||||
|
||||
test('aliases to rowid are non-nullable', () {
|
||||
final engine = SqlEngine();
|
||||
final stmt =
|
||||
engine.parse('CREATE TABLE foo (id INTEGER PRIMARY KEY);').rootNode;
|
||||
|
||||
final table = engine.schemaReader.read(stmt as CreateTableStatement);
|
||||
expect(table.resolvedColumns.single.type,
|
||||
const ResolvedType(type: BasicType.int, nullable: false));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue