From 2fc780e66b67f14a2f37179fbde48710d521688e Mon Sep 17 00:00:00 2001 From: Shashwat12-egov Date: Fri, 22 Nov 2024 16:22:15 +0530 Subject: [PATCH] Changed the attribute datatype from string to bool in digit data model package --- .../local_store/sql_store/sql_store.g.dart | 27 ++++++++++--------- .../sql_store/tables/attributes.dart | 2 +- .../lib/models/entities/attributes.dart | 4 +-- .../models/entities/attributes.mapper.dart | 12 ++++----- .../lib/pages/survey_form_view.dart | 2 +- .../test/constants/test_constants.dart | 4 +-- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.g.dart b/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.g.dart index 37daa8c69..d7b3f9bbf 100644 --- a/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.g.dart +++ b/packages/digit_data_model/lib/data/local_store/sql_store/sql_store.g.dart @@ -25164,9 +25164,12 @@ class $AttributesTable extends Attributes static const VerificationMeta _isActiveMeta = const VerificationMeta('isActive'); @override - late final GeneratedColumn isActive = GeneratedColumn( + late final GeneratedColumn isActive = GeneratedColumn( 'is_active', aliasedName, true, - type: DriftSqlType.string, requiredDuringInsert: false); + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('CHECK ("is_active" IN (0, 1))')); static const VerificationMeta _requiredMeta = const VerificationMeta('required'); @override @@ -25447,7 +25450,7 @@ class $AttributesTable extends Attributes values: attachedDatabase.typeMapping .read(DriftSqlType.string, data['${effectivePrefix}values']), isActive: attachedDatabase.typeMapping - .read(DriftSqlType.string, data['${effectivePrefix}is_active']), + .read(DriftSqlType.bool, data['${effectivePrefix}is_active']), required: attachedDatabase.typeMapping .read(DriftSqlType.bool, data['${effectivePrefix}required']), regex: attachedDatabase.typeMapping @@ -25496,7 +25499,7 @@ class Attribute extends DataClass implements Insertable { final String? tenantId; final String? code; final String? values; - final String? isActive; + final bool? isActive; final bool? required; final String? regex; final int? order; @@ -25559,7 +25562,7 @@ class Attribute extends DataClass implements Insertable { map['values'] = Variable(values); } if (!nullToAbsent || isActive != null) { - map['is_active'] = Variable(isActive); + map['is_active'] = Variable(isActive); } if (!nullToAbsent || required != null) { map['required'] = Variable(required); @@ -25689,7 +25692,7 @@ class Attribute extends DataClass implements Insertable { tenantId: serializer.fromJson(json['tenantId']), code: serializer.fromJson(json['code']), values: serializer.fromJson(json['values']), - isActive: serializer.fromJson(json['isActive']), + isActive: serializer.fromJson(json['isActive']), required: serializer.fromJson(json['required']), regex: serializer.fromJson(json['regex']), order: serializer.fromJson(json['order']), @@ -25720,7 +25723,7 @@ class Attribute extends DataClass implements Insertable { 'tenantId': serializer.toJson(tenantId), 'code': serializer.toJson(code), 'values': serializer.toJson(values), - 'isActive': serializer.toJson(isActive), + 'isActive': serializer.toJson(isActive), 'required': serializer.toJson(required), 'regex': serializer.toJson(regex), 'order': serializer.toJson(order), @@ -25747,7 +25750,7 @@ class Attribute extends DataClass implements Insertable { Value tenantId = const Value.absent(), Value code = const Value.absent(), Value values = const Value.absent(), - Value isActive = const Value.absent(), + Value isActive = const Value.absent(), Value required = const Value.absent(), Value regex = const Value.absent(), Value order = const Value.absent(), @@ -25902,7 +25905,7 @@ class AttributesCompanion extends UpdateCompanion { final Value tenantId; final Value code; final Value values; - final Value isActive; + final Value isActive; final Value required; final Value regex; final Value order; @@ -25979,7 +25982,7 @@ class AttributesCompanion extends UpdateCompanion { Expression? tenantId, Expression? code, Expression? values, - Expression? isActive, + Expression? isActive, Expression? required, Expression? regex, Expression? order, @@ -26035,7 +26038,7 @@ class AttributesCompanion extends UpdateCompanion { Value? tenantId, Value? code, Value? values, - Value? isActive, + Value? isActive, Value? required, Value? regex, Value? order, @@ -26103,7 +26106,7 @@ class AttributesCompanion extends UpdateCompanion { map['values'] = Variable(values.value); } if (isActive.present) { - map['is_active'] = Variable(isActive.value); + map['is_active'] = Variable(isActive.value); } if (required.present) { map['required'] = Variable(required.value); diff --git a/packages/digit_data_model/lib/data/local_store/sql_store/tables/attributes.dart b/packages/digit_data_model/lib/data/local_store/sql_store/tables/attributes.dart index 82d1ecdb3..18e330a5c 100644 --- a/packages/digit_data_model/lib/data/local_store/sql_store/tables/attributes.dart +++ b/packages/digit_data_model/lib/data/local_store/sql_store/tables/attributes.dart @@ -9,7 +9,7 @@ class Attributes extends Table { TextColumn get tenantId => text().nullable()(); TextColumn get code => text().nullable()(); TextColumn get values => text().nullable()(); - TextColumn get isActive => text().nullable()(); + BoolColumn get isActive => boolean().nullable()(); BoolColumn get required => boolean().nullable()(); TextColumn get regex => text().nullable()(); IntColumn get order => integer().nullable()(); diff --git a/packages/digit_data_model/lib/models/entities/attributes.dart b/packages/digit_data_model/lib/models/entities/attributes.dart index 29f317708..1af0a9f29 100644 --- a/packages/digit_data_model/lib/models/entities/attributes.dart +++ b/packages/digit_data_model/lib/models/entities/attributes.dart @@ -18,7 +18,7 @@ class AttributesSearchModel extends EntitySearchModel final String? referenceId; final String? tenantId; final String? code; - final String? isActive; + final bool? isActive; final bool? required; final String? regex; final int? order; @@ -62,7 +62,7 @@ class AttributesModel extends EntityModel with AttributesModelMappable { final String? tenantId; final String? code; final List? values; - final String? isActive; + final bool? isActive; final bool? required; final String? regex; final int? order; diff --git a/packages/digit_data_model/lib/models/entities/attributes.mapper.dart b/packages/digit_data_model/lib/models/entities/attributes.mapper.dart index 2b9f5e138..b5f207866 100644 --- a/packages/digit_data_model/lib/models/entities/attributes.mapper.dart +++ b/packages/digit_data_model/lib/models/entities/attributes.mapper.dart @@ -36,8 +36,8 @@ class AttributesSearchModelMapper static String? _$code(AttributesSearchModel v) => v.code; static const Field _f$code = Field('code', _$code, opt: true); - static String? _$isActive(AttributesSearchModel v) => v.isActive; - static const Field _f$isActive = + static bool? _$isActive(AttributesSearchModel v) => v.isActive; + static const Field _f$isActive = Field('isActive', _$isActive, opt: true); static bool? _$required(AttributesSearchModel v) => v.required; static const Field _f$required = @@ -167,7 +167,7 @@ abstract class AttributesSearchModelCopyWith< String? referenceId, String? tenantId, String? code, - String? isActive, + bool? isActive, bool? required, String? regex, int? order, @@ -270,8 +270,8 @@ class AttributesModelMapper extends SubClassMapperBase { static List? _$values(AttributesModel v) => v.values; static const Field> _f$values = Field('values', _$values, opt: true); - static String? _$isActive(AttributesModel v) => v.isActive; - static const Field _f$isActive = + static bool? _$isActive(AttributesModel v) => v.isActive; + static const Field _f$isActive = Field('isActive', _$isActive, opt: true); static bool? _$required(AttributesModel v) => v.required; static const Field _f$required = @@ -429,7 +429,7 @@ abstract class AttributesModelCopyWith<$R, $In extends AttributesModel, $Out> String? tenantId, String? code, List? values, - String? isActive, + bool? isActive, bool? required, String? regex, int? order, diff --git a/packages/survey_form/lib/pages/survey_form_view.dart b/packages/survey_form/lib/pages/survey_form_view.dart index cb98f1730..d43db2d6d 100644 --- a/packages/survey_form/lib/pages/survey_form_view.dart +++ b/packages/survey_form/lib/pages/survey_form_view.dart @@ -379,7 +379,7 @@ class SurveyFormViewPageState extends LocalizedState { textAlign: TextAlign.left, ), ), - ...initialAttributes!.where((att) => att.isActive.toString() == 'true').map(( + ...initialAttributes!.where((att) => att.isActive == true).map(( e, ) { int index = (initialAttributes ?? []).indexOf(e); diff --git a/packages/survey_form/test/constants/test_constants.dart b/packages/survey_form/test/constants/test_constants.dart index ad95b6b5a..1e51fd3f1 100644 --- a/packages/survey_form/test/constants/test_constants.dart +++ b/packages/survey_form/test/constants/test_constants.dart @@ -46,7 +46,7 @@ class ServiceTestConstants { dataType: testDataType, values: null, required: true, - isActive: 'true', + isActive: true, regex: null, order: 1, ); @@ -57,7 +57,7 @@ class ServiceTestConstants { dataType: testDataType, values: null, required: true, - isActive: 'true', + isActive: true, regex: null, order: 1, );