mirror of https://github.com/AMT-Cheif/drift.git
Remove drift_dev's ColumnType
This commit is contained in:
parent
4d9b505703
commit
867f8cbfed
|
@ -439,16 +439,16 @@ class ColumnParser {
|
|||
);
|
||||
}
|
||||
|
||||
ColumnType _startMethodToColumnType(String name) {
|
||||
DriftSqlType _startMethodToColumnType(String name) {
|
||||
return const {
|
||||
startBool: ColumnType.boolean,
|
||||
startString: ColumnType.text,
|
||||
startInt: ColumnType.integer,
|
||||
startInt64: ColumnType.bigInt,
|
||||
startEnum: ColumnType.integer,
|
||||
startDateTime: ColumnType.datetime,
|
||||
startBlob: ColumnType.blob,
|
||||
startReal: ColumnType.real,
|
||||
startBool: DriftSqlType.bool,
|
||||
startString: DriftSqlType.string,
|
||||
startInt: DriftSqlType.int,
|
||||
startInt64: DriftSqlType.bigInt,
|
||||
startEnum: DriftSqlType.int,
|
||||
startDateTime: DriftSqlType.dateTime,
|
||||
startBlob: DriftSqlType.blob,
|
||||
startReal: DriftSqlType.double,
|
||||
}[name]!;
|
||||
}
|
||||
|
||||
|
|
|
@ -166,15 +166,15 @@ class ViewParser {
|
|||
return results.whereType();
|
||||
}
|
||||
|
||||
ColumnType? _dartTypeToColumnType(String name) {
|
||||
DriftSqlType? _dartTypeToColumnType(String name) {
|
||||
return const {
|
||||
'bool': ColumnType.boolean,
|
||||
'String': ColumnType.text,
|
||||
'int': ColumnType.integer,
|
||||
'BigInt': ColumnType.bigInt,
|
||||
'DateTime': ColumnType.datetime,
|
||||
'Uint8List': ColumnType.blob,
|
||||
'double': ColumnType.real,
|
||||
'bool': DriftSqlType.bool,
|
||||
'String': DriftSqlType.string,
|
||||
'int': DriftSqlType.int,
|
||||
'BigInt': DriftSqlType.bigInt,
|
||||
'DateTime': DriftSqlType.dateTime,
|
||||
'Uint8List': DriftSqlType.blob,
|
||||
'double': DriftSqlType.double,
|
||||
}[name];
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ ExistingRowClass? validateExistingClass(
|
|||
UsedTypeConverter? readTypeConverter(
|
||||
LibraryElement library,
|
||||
Expression dartExpression,
|
||||
ColumnType columnType,
|
||||
DriftSqlType columnType,
|
||||
bool columnIsNullable,
|
||||
void Function(String) reportError,
|
||||
HelperLibrary helper, {
|
||||
|
@ -206,7 +206,7 @@ void _checkParameterType(
|
|||
}
|
||||
|
||||
void _checkType(
|
||||
ColumnType columnType,
|
||||
DriftSqlType columnType,
|
||||
bool columnIsNullable,
|
||||
UsedTypeConverter? typeConverter,
|
||||
DartType typeToCheck,
|
||||
|
@ -228,7 +228,7 @@ void _checkType(
|
|||
// We don't get a Uint8List from the type provider unfortunately, but as it
|
||||
// cannot be extended we can just check for that manually.
|
||||
final isAllowedUint8List = typeConverter == null &&
|
||||
columnType == ColumnType.blob &&
|
||||
columnType == DriftSqlType.blob &&
|
||||
typeToCheck is InterfaceType &&
|
||||
typeToCheck.element.name == 'Uint8List' &&
|
||||
typeToCheck.element.library.name == 'dart.typed_data';
|
||||
|
@ -241,23 +241,23 @@ void _checkType(
|
|||
}
|
||||
|
||||
extension on TypeProvider {
|
||||
DartType typeFor(ColumnType type) {
|
||||
DartType typeFor(DriftSqlType type) {
|
||||
switch (type) {
|
||||
case ColumnType.integer:
|
||||
case DriftSqlType.int:
|
||||
return intType;
|
||||
case ColumnType.bigInt:
|
||||
case DriftSqlType.bigInt:
|
||||
return intElement.library.getType('BigInt')!.instantiate(
|
||||
typeArguments: const [], nullabilitySuffix: NullabilitySuffix.none);
|
||||
case ColumnType.text:
|
||||
case DriftSqlType.string:
|
||||
return stringType;
|
||||
case ColumnType.boolean:
|
||||
case DriftSqlType.bool:
|
||||
return boolType;
|
||||
case ColumnType.datetime:
|
||||
case DriftSqlType.dateTime:
|
||||
return intElement.library.getType('DateTime')!.instantiate(
|
||||
typeArguments: const [], nullabilitySuffix: NullabilitySuffix.none);
|
||||
case ColumnType.blob:
|
||||
case DriftSqlType.blob:
|
||||
return listType(intType);
|
||||
case ColumnType.real:
|
||||
case DriftSqlType.double:
|
||||
return doubleType;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ class CreateTableReader {
|
|||
}
|
||||
|
||||
Future<UsedTypeConverter?> _readTypeConverter(
|
||||
ColumnType sqlType, bool nullable, MappedBy mapper) async {
|
||||
DriftSqlType sqlType, bool nullable, MappedBy mapper) async {
|
||||
final code = mapper.mapper.dartCode;
|
||||
|
||||
Expression expression;
|
||||
|
|
|
@ -49,52 +49,53 @@ class TypeMapper {
|
|||
return engineTable;
|
||||
}
|
||||
|
||||
ResolvedType resolveForColumnType(ColumnType type, {TypeHint? overrideHint}) {
|
||||
ResolvedType resolveForColumnType(DriftSqlType type,
|
||||
{TypeHint? overrideHint}) {
|
||||
switch (type) {
|
||||
case ColumnType.integer:
|
||||
case DriftSqlType.int:
|
||||
return ResolvedType(type: BasicType.int, hint: overrideHint);
|
||||
case ColumnType.bigInt:
|
||||
case DriftSqlType.bigInt:
|
||||
return ResolvedType(
|
||||
type: BasicType.int, hint: overrideHint ?? const IsBigInt());
|
||||
case ColumnType.text:
|
||||
case DriftSqlType.string:
|
||||
return ResolvedType(type: BasicType.text, hint: overrideHint);
|
||||
case ColumnType.boolean:
|
||||
case DriftSqlType.bool:
|
||||
return ResolvedType(
|
||||
type: BasicType.int, hint: overrideHint ?? const IsBoolean());
|
||||
case ColumnType.datetime:
|
||||
case DriftSqlType.dateTime:
|
||||
return ResolvedType(
|
||||
type: BasicType.int, hint: overrideHint ?? const IsDateTime());
|
||||
case ColumnType.blob:
|
||||
case DriftSqlType.blob:
|
||||
return ResolvedType(type: BasicType.blob, hint: overrideHint);
|
||||
case ColumnType.real:
|
||||
case DriftSqlType.double:
|
||||
return ResolvedType(type: BasicType.real, hint: overrideHint);
|
||||
}
|
||||
}
|
||||
|
||||
ColumnType resolvedToMoor(ResolvedType? type) {
|
||||
DriftSqlType resolvedToMoor(ResolvedType? type) {
|
||||
if (type == null) {
|
||||
return ColumnType.text;
|
||||
return DriftSqlType.string;
|
||||
}
|
||||
|
||||
switch (type.type) {
|
||||
case null:
|
||||
case BasicType.nullType:
|
||||
return ColumnType.text;
|
||||
return DriftSqlType.string;
|
||||
case BasicType.int:
|
||||
if (type.hint is IsBoolean) {
|
||||
return ColumnType.boolean;
|
||||
return DriftSqlType.bool;
|
||||
} else if (type.hint is IsDateTime) {
|
||||
return ColumnType.datetime;
|
||||
return DriftSqlType.dateTime;
|
||||
} else if (type.hint is IsBigInt) {
|
||||
return ColumnType.bigInt;
|
||||
return DriftSqlType.bigInt;
|
||||
}
|
||||
return ColumnType.integer;
|
||||
return DriftSqlType.int;
|
||||
case BasicType.real:
|
||||
return ColumnType.real;
|
||||
return DriftSqlType.double;
|
||||
case BasicType.text:
|
||||
return ColumnType.text;
|
||||
return DriftSqlType.string;
|
||||
case BasicType.blob:
|
||||
return ColumnType.blob;
|
||||
return DriftSqlType.blob;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,7 +280,7 @@ class TypeMapper {
|
|||
final type = placeholder.when(
|
||||
isExpression: (e) {
|
||||
final foundType = context.typeOf(e);
|
||||
ColumnType? columnType;
|
||||
DriftSqlType? columnType;
|
||||
if (foundType.type != null) {
|
||||
columnType = resolvedToMoor(foundType.type);
|
||||
}
|
||||
|
|
|
@ -3,13 +3,7 @@ import 'package:analyzer/dart/element/element.dart';
|
|||
import 'package:drift_dev/src/analyzer/options.dart';
|
||||
import 'package:sqlparser/sqlparser.dart' show ReferenceAction;
|
||||
|
||||
import 'declarations/declaration.dart';
|
||||
import 'table.dart';
|
||||
import 'types.dart';
|
||||
import 'used_type_converter.dart';
|
||||
|
||||
/// The column types in sql.
|
||||
enum ColumnType { integer, bigInt, text, boolean, datetime, blob, real }
|
||||
import 'model.dart';
|
||||
|
||||
/// Name of a column. Contains additional info on whether the name was chosen
|
||||
/// implicitly (based on the dart getter name) or explicitly (via an named())
|
||||
|
@ -59,7 +53,7 @@ class DriftColumn implements HasDeclaration, HasType {
|
|||
|
||||
/// The sql type of this column
|
||||
@override
|
||||
final ColumnType type;
|
||||
final DriftSqlType type;
|
||||
|
||||
/// The name of this column, as chosen by the user
|
||||
final ColumnName name;
|
||||
|
@ -112,20 +106,6 @@ class DriftColumn implements HasDeclaration, HasType {
|
|||
/// Parent table
|
||||
DriftTable? table;
|
||||
|
||||
/// The column type from the dsl library. For instance, if a table has
|
||||
/// declared an `IntColumn`, the matching dsl column name would also be an
|
||||
/// `IntColumn`.
|
||||
@Deprecated('Use Column<innerColumnType()> instead')
|
||||
String get dslColumnTypeName => const {
|
||||
ColumnType.boolean: 'BoolColumn',
|
||||
ColumnType.text: 'TextColumn',
|
||||
ColumnType.integer: 'IntColumn',
|
||||
ColumnType.bigInt: 'BigIntColumn',
|
||||
ColumnType.datetime: 'DateTimeColumn',
|
||||
ColumnType.blob: 'BlobColumn',
|
||||
ColumnType.real: 'RealColumn',
|
||||
}[type]!;
|
||||
|
||||
@override
|
||||
bool get isArray => false;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:recase/recase.dart';
|
||||
|
||||
export 'package:drift/drift.dart' show DriftSqlType;
|
||||
export 'base_entity.dart';
|
||||
export 'column.dart';
|
||||
export 'database.dart';
|
||||
|
|
|
@ -99,7 +99,7 @@ abstract class SqlQuery {
|
|||
/// The placeholders in this query which are bound and converted to sql at
|
||||
/// runtime. For instance, in `SELECT * FROM tbl WHERE $expr`, the `expr` is
|
||||
/// going to be a [FoundDartPlaceholder] with the type
|
||||
/// [ExpressionDartPlaceholderType] and [ColumnType.boolean]. We will
|
||||
/// [ExpressionDartPlaceholderType] and [DriftSqlType.bool]. We will
|
||||
/// generate a method which has a `Expression<bool, BoolType> expr` parameter.
|
||||
late List<FoundDartPlaceholder> placeholders;
|
||||
|
||||
|
@ -453,7 +453,7 @@ class MatchingMoorTable {
|
|||
class ResultColumn implements HasType {
|
||||
final String name;
|
||||
@override
|
||||
final ColumnType type;
|
||||
final DriftSqlType type;
|
||||
@override
|
||||
final bool nullable;
|
||||
|
||||
|
@ -611,7 +611,7 @@ class FoundVariable extends FoundElement implements HasType {
|
|||
|
||||
/// The (inferred) type for this variable.
|
||||
@override
|
||||
final ColumnType type;
|
||||
final DriftSqlType type;
|
||||
|
||||
/// The type converter to apply before writing this value.
|
||||
@override
|
||||
|
@ -721,7 +721,7 @@ class SimpleDartPlaceholderType extends DartPlaceholderType {
|
|||
|
||||
class ExpressionDartPlaceholderType extends DartPlaceholderType {
|
||||
/// The sql type of this expression.
|
||||
final ColumnType? columnType;
|
||||
final DriftSqlType? columnType;
|
||||
final Expression? defaultValue;
|
||||
|
||||
ExpressionDartPlaceholderType(this.columnType, this.defaultValue);
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:drift/drift.dart' show UpdateKind;
|
||||
import 'package:drift_dev/src/analyzer/options.dart';
|
||||
import 'package:drift_dev/src/model/used_type_converter.dart';
|
||||
import 'package:drift_dev/writer.dart';
|
||||
import 'package:recase/recase.dart';
|
||||
import 'package:sqlparser/sqlparser.dart';
|
||||
|
||||
import 'base_entity.dart';
|
||||
import 'column.dart';
|
||||
import 'declarations/declaration.dart';
|
||||
import 'model.dart';
|
||||
|
||||
/// A parsed table, declared in code by extending `Table` and referencing that
|
||||
/// table in `@UseMoor` or `@UseDao`.
|
||||
|
@ -194,7 +191,7 @@ class DriftTable extends DriftEntityWithResultSet {
|
|||
final isWithoutRowId = overrideWithoutRowId ?? false;
|
||||
final fullPk = fullPrimaryKey;
|
||||
final isAliasForRowId = !isWithoutRowId &&
|
||||
column.type == ColumnType.integer &&
|
||||
column.type == DriftSqlType.int &&
|
||||
fullPk.length == 1 &&
|
||||
fullPk.single == column;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import 'package:analyzer/dart/element/nullability_suffix.dart';
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift_dev/src/model/model.dart';
|
||||
import 'package:drift_dev/src/utils/type_utils.dart';
|
||||
import 'package:drift_dev/writer.dart';
|
||||
|
@ -19,7 +18,7 @@ abstract class HasType {
|
|||
bool get isArray;
|
||||
|
||||
/// The associated sql type.
|
||||
ColumnType get type;
|
||||
DriftSqlType get type;
|
||||
|
||||
/// The applied type converter, or null.
|
||||
UsedTypeConverter? get typeConverter;
|
||||
|
@ -99,25 +98,25 @@ extension OperationOnTypes on HasType {
|
|||
String code;
|
||||
|
||||
switch (type) {
|
||||
case ColumnType.integer:
|
||||
case DriftSqlType.int:
|
||||
code = 'int';
|
||||
break;
|
||||
case ColumnType.bigInt:
|
||||
case DriftSqlType.bigInt:
|
||||
code = 'BigInt';
|
||||
break;
|
||||
case ColumnType.text:
|
||||
case DriftSqlType.string:
|
||||
code = 'String';
|
||||
break;
|
||||
case ColumnType.boolean:
|
||||
case DriftSqlType.bool:
|
||||
code = 'bool';
|
||||
break;
|
||||
case ColumnType.datetime:
|
||||
case DriftSqlType.dateTime:
|
||||
code = 'DateTime';
|
||||
break;
|
||||
case ColumnType.blob:
|
||||
case DriftSqlType.blob:
|
||||
code = 'Uint8List';
|
||||
break;
|
||||
case ColumnType.real:
|
||||
case DriftSqlType.double:
|
||||
code = 'double';
|
||||
break;
|
||||
}
|
||||
|
@ -138,46 +137,26 @@ extension OperationOnTypes on HasType {
|
|||
|
||||
return variableTypeCode();
|
||||
}
|
||||
|
||||
DriftSqlType sqlType() {
|
||||
// todo: Just replace ColumnType with DriftSqlType now?
|
||||
switch (type) {
|
||||
case ColumnType.integer:
|
||||
return DriftSqlType.int;
|
||||
case ColumnType.bigInt:
|
||||
return DriftSqlType.bigInt;
|
||||
case ColumnType.boolean:
|
||||
return DriftSqlType.bool;
|
||||
case ColumnType.datetime:
|
||||
return DriftSqlType.dateTime;
|
||||
case ColumnType.text:
|
||||
return DriftSqlType.string;
|
||||
case ColumnType.blob:
|
||||
return DriftSqlType.blob;
|
||||
case ColumnType.real:
|
||||
return DriftSqlType.double;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const Map<ColumnType, String> dartTypeNames = {
|
||||
ColumnType.boolean: 'bool',
|
||||
ColumnType.text: 'String',
|
||||
ColumnType.integer: 'int',
|
||||
ColumnType.bigInt: 'BigInt',
|
||||
ColumnType.datetime: 'DateTime',
|
||||
ColumnType.blob: 'Uint8List',
|
||||
ColumnType.real: 'double',
|
||||
const Map<DriftSqlType, String> dartTypeNames = {
|
||||
DriftSqlType.bool: 'bool',
|
||||
DriftSqlType.string: 'String',
|
||||
DriftSqlType.int: 'int',
|
||||
DriftSqlType.bigInt: 'BigInt',
|
||||
DriftSqlType.dateTime: 'DateTime',
|
||||
DriftSqlType.blob: 'Uint8List',
|
||||
DriftSqlType.double: 'double',
|
||||
};
|
||||
|
||||
/// Maps from a column type to code that can be used to create a variable of the
|
||||
/// respective type.
|
||||
const Map<ColumnType, String> createVariable = {
|
||||
ColumnType.boolean: 'Variable.withBool',
|
||||
ColumnType.text: 'Variable.withString',
|
||||
ColumnType.integer: 'Variable.withInt',
|
||||
ColumnType.bigInt: 'Variable.withBigInt',
|
||||
ColumnType.datetime: 'Variable.withDateTime',
|
||||
ColumnType.blob: 'Variable.withBlob',
|
||||
ColumnType.real: 'Variable.withReal',
|
||||
const Map<DriftSqlType, String> createVariable = {
|
||||
DriftSqlType.bool: 'Variable.withBool',
|
||||
DriftSqlType.string: 'Variable.withString',
|
||||
DriftSqlType.int: 'Variable.withInt',
|
||||
DriftSqlType.bigInt: 'Variable.withBigInt',
|
||||
DriftSqlType.dateTime: 'Variable.withDateTime',
|
||||
DriftSqlType.blob: 'Variable.withBlob',
|
||||
DriftSqlType.double: 'Variable.withReal',
|
||||
};
|
||||
|
|
|
@ -118,7 +118,7 @@ class SchemaWriter {
|
|||
return {
|
||||
'name': column.name.name,
|
||||
'getter_name': column.dartGetterName,
|
||||
'moor_type': column.type.toString(),
|
||||
'moor_type': column.type.toSerializedString(),
|
||||
'nullable': column.nullable,
|
||||
'customConstraints': column.customConstraints,
|
||||
if (constraints.isNotEmpty && column.customConstraints == null)
|
||||
|
@ -316,8 +316,8 @@ class SchemaReader {
|
|||
|
||||
DriftColumn _readColumn(Map<String, dynamic> data) {
|
||||
final name = data['name'] as String;
|
||||
final moorType = ColumnType.values
|
||||
.firstWhere((type) => type.toString() == data['moor_type']);
|
||||
final columnType =
|
||||
_SerializeSqlType.deserialize(data['moor_type'] as String);
|
||||
final nullable = data['nullable'] as bool;
|
||||
final customConstraints = data['customConstraints'] as String?;
|
||||
final defaultConstraints = data['defaultConstraints'] as String?;
|
||||
|
@ -334,7 +334,7 @@ class SchemaReader {
|
|||
return DriftColumn(
|
||||
name: ColumnName.explicitly(name),
|
||||
dartGetterName: getterName ?? ReCase(name).camelCase,
|
||||
type: moorType,
|
||||
type: columnType,
|
||||
nullable: nullable,
|
||||
defaultArgument: data['default_dart'] as String?,
|
||||
customConstraints: customConstraints,
|
||||
|
@ -357,3 +357,49 @@ class SchemaReader {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// There used to be another enum to represent columns that has since been
|
||||
// replaced with DriftSqlType. We still need to reflect the old description in
|
||||
// the serialized format.
|
||||
extension _SerializeSqlType on DriftSqlType {
|
||||
static DriftSqlType deserialize(String description) {
|
||||
switch (description) {
|
||||
case 'ColumnType.boolean':
|
||||
return DriftSqlType.bool;
|
||||
case 'ColumnType.text':
|
||||
return DriftSqlType.string;
|
||||
case 'ColumnType.bigInt':
|
||||
return DriftSqlType.bigInt;
|
||||
case 'ColumnType.integer':
|
||||
return DriftSqlType.int;
|
||||
case 'ColumnType.datetime':
|
||||
return DriftSqlType.dateTime;
|
||||
case 'ColumnType.blob':
|
||||
return DriftSqlType.blob;
|
||||
case 'ColumnType.real':
|
||||
return DriftSqlType.double;
|
||||
default:
|
||||
throw ArgumentError.value(
|
||||
description, 'description', 'Not a known column type');
|
||||
}
|
||||
}
|
||||
|
||||
String toSerializedString() {
|
||||
switch (this) {
|
||||
case DriftSqlType.bool:
|
||||
return 'ColumnType.boolean';
|
||||
case DriftSqlType.string:
|
||||
return 'ColumnType.text';
|
||||
case DriftSqlType.bigInt:
|
||||
return 'ColumnType.bigInt';
|
||||
case DriftSqlType.int:
|
||||
return 'ColumnType.integer';
|
||||
case DriftSqlType.dateTime:
|
||||
return 'ColumnType.datetime';
|
||||
case DriftSqlType.blob:
|
||||
return 'ColumnType.blob';
|
||||
case DriftSqlType.double:
|
||||
return 'ColumnType.real';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -349,7 +349,7 @@ class RowMappingWriter {
|
|||
final columnName = column.name.name;
|
||||
final rawData = "data['\${effectivePrefix}$columnName']";
|
||||
|
||||
final sqlType = column.sqlType();
|
||||
final sqlType = column.type.toString();
|
||||
var loadType = '$databaseGetter.options.types.read($sqlType, $rawData)';
|
||||
|
||||
if (!column.nullable) {
|
||||
|
|
|
@ -39,7 +39,7 @@ abstract class TableOrViewWriter {
|
|||
}
|
||||
}
|
||||
|
||||
additionalParams['type'] = column.sqlType().toString();
|
||||
additionalParams['type'] = column.type.toString();
|
||||
|
||||
if (tableOrView is DriftTable) {
|
||||
additionalParams['requiredDuringInsert'] = (tableOrView as DriftTable)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:drift/sqlite_keywords.dart';
|
||||
import 'package:sqlparser/sqlparser.dart';
|
||||
|
||||
import '../../model/column.dart';
|
||||
import '../../model/model.dart';
|
||||
|
||||
String defaultConstraints(DriftColumn column) {
|
||||
final defaultConstraints = <String>[];
|
||||
|
@ -54,7 +54,7 @@ String defaultConstraints(DriftColumn column) {
|
|||
}
|
||||
}
|
||||
|
||||
if (column.type == ColumnType.boolean) {
|
||||
if (column.type == DriftSqlType.bool) {
|
||||
final name = escapeIfNeeded(column.name.name);
|
||||
defaultConstraints.add('CHECK ($name IN (0, 1))');
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ WITH alias("first", second) AS (SELECT * FROM foo) SELECT * FROM alias;
|
|||
expect(resultSet.singleColumn, isTrue);
|
||||
expect(resultSet.needsOwnClass, isFalse);
|
||||
expect(resultSet.columns.map(resultSet.dartNameFor), ['x']);
|
||||
expect(resultSet.columns.map((c) => c.type), [ColumnType.integer]);
|
||||
expect(resultSet.columns.map((c) => c.type), [DriftSqlType.int]);
|
||||
});
|
||||
|
||||
test('finds the underlying table when aliased through CFE', () {
|
||||
|
|
|
@ -29,7 +29,7 @@ void main() {
|
|||
|
||||
state.close();
|
||||
|
||||
expect(column.type, ColumnType.integer);
|
||||
expect(column.type, DriftSqlType.int);
|
||||
expect(
|
||||
column.typeConverter,
|
||||
isA<UsedTypeConverter>()
|
||||
|
|
|
@ -111,7 +111,7 @@ wrongArgs: SELECT sin(oid, foo) FROM numbers;
|
|||
expect(
|
||||
queryInA.resultSet.columns.single,
|
||||
const TypeMatcher<ResultColumn>()
|
||||
.having((e) => e.type, 'type', ColumnType.real),
|
||||
.having((e) => e.type, 'type', DriftSqlType.double),
|
||||
);
|
||||
|
||||
final fileB = await state.analyze('package:foo/b.moor');
|
||||
|
|
|
@ -114,7 +114,7 @@ class ProgrammingLanguages extends Table {
|
|||
|
||||
final librariesQuery = database.queries!
|
||||
.singleWhere((q) => q.name == 'findLibraries') as SqlSelectQuery;
|
||||
expect(librariesQuery.variables.single.type, ColumnType.text);
|
||||
expect(librariesQuery.variables.single.type, DriftSqlType.string);
|
||||
expect(librariesQuery.declaredInMoorFile, isTrue);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -49,9 +49,9 @@ totalDurationByArtist:
|
|||
expect(
|
||||
totalDurationByArtist,
|
||||
returnsColumns({
|
||||
'id': ColumnType.integer,
|
||||
'name': ColumnType.text,
|
||||
'duration': ColumnType.integer,
|
||||
'id': DriftSqlType.int,
|
||||
'name': DriftSqlType.string,
|
||||
'duration': DriftSqlType.int,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
|
|
@ -52,9 +52,9 @@ SELECT * FROM total_duration_by_artist_view;
|
|||
expect(
|
||||
totalDurationByArtist,
|
||||
returnsColumns({
|
||||
'id': ColumnType.integer,
|
||||
'name': ColumnType.text,
|
||||
'duration': ColumnType.integer,
|
||||
'id': DriftSqlType.int,
|
||||
'name': DriftSqlType.string,
|
||||
'duration': DriftSqlType.int,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
|
|
@ -26,7 +26,7 @@ bar(?1 AS TEXT, :foo AS BOOLEAN): SELECT ?, :foo;
|
|||
expect(resultSet.matchingTable, isNull);
|
||||
expect(resultSet.columns.map((c) => c.name), ['?', ':foo']);
|
||||
expect(resultSet.columns.map((c) => c.type),
|
||||
[ColumnType.text, ColumnType.boolean]);
|
||||
[DriftSqlType.string, DriftSqlType.bool]);
|
||||
});
|
||||
|
||||
test('reads REQUIRED syntax', () async {
|
||||
|
|
|
@ -52,7 +52,7 @@ class TestState {
|
|||
}
|
||||
|
||||
// Matchers
|
||||
Matcher returnsColumns(Map<String, ColumnType> columns) {
|
||||
Matcher returnsColumns(Map<String, DriftSqlType> columns) {
|
||||
return _HasInferredColumnTypes(columns);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue