@reldens/storage 0.57.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -130,12 +130,14 @@ class EntitiesGeneration extends BaseGenerator
|
|
|
130
130
|
let column = columns[columnName];
|
|
131
131
|
let propertyKey = titleProperty && titleProperty === columnName ? '[titleProperty]' : columnName;
|
|
132
132
|
if('id' === columnName){
|
|
133
|
-
|
|
133
|
+
let idType = column.type.toLowerCase();
|
|
134
|
+
propertiesConfig.push(columnName+': {\n dbType: \''+idType+'\'\n }');
|
|
134
135
|
continue;
|
|
135
136
|
}
|
|
136
137
|
let props = this.getPropertyAttributes(column);
|
|
137
138
|
if(0 === props.length){
|
|
138
|
-
|
|
139
|
+
let dbType = column.type.toLowerCase();
|
|
140
|
+
propertiesConfig.push(propertyKey+': {\n dbType: \''+dbType+'\'\n }');
|
|
139
141
|
continue;
|
|
140
142
|
}
|
|
141
143
|
propertiesConfig.push(
|
|
@@ -151,6 +153,7 @@ class EntitiesGeneration extends BaseGenerator
|
|
|
151
153
|
let type = column.type.toLowerCase();
|
|
152
154
|
this.addTypeAttribute(props, column, type);
|
|
153
155
|
this.addRequiredAttribute(props, column);
|
|
156
|
+
props.push('dbType: \''+type+'\'');
|
|
154
157
|
return props;
|
|
155
158
|
}
|
|
156
159
|
|
|
@@ -251,7 +251,7 @@ class PrismaDriver extends BaseDriver
|
|
|
251
251
|
if(sc.hasOwn(this.referenceFields, key) && !sc.isArray(operatorValue)){
|
|
252
252
|
operatorValue = this.castNumericValue(operatorValue, this.referenceFields[key]);
|
|
253
253
|
}
|
|
254
|
-
processedFilters[key] = this.applyOperator(operatorValue, value.operator);
|
|
254
|
+
processedFilters[key] = this.applyOperator(operatorValue, value.operator, key);
|
|
255
255
|
continue;
|
|
256
256
|
}
|
|
257
257
|
if(sc.isObject(value) && !sc.isArray(value)){
|
|
@@ -742,11 +742,11 @@ class PrismaDriver extends BaseDriver
|
|
|
742
742
|
filter[field] = processedValue;
|
|
743
743
|
return filter;
|
|
744
744
|
}
|
|
745
|
-
filter[field] = this.applyOperator(processedValue, operator);
|
|
745
|
+
filter[field] = this.applyOperator(processedValue, operator, field);
|
|
746
746
|
return filter;
|
|
747
747
|
}
|
|
748
748
|
|
|
749
|
-
applyOperator(value, operator)
|
|
749
|
+
applyOperator(value, operator, fieldName = null)
|
|
750
750
|
{
|
|
751
751
|
let operatorsMap = {
|
|
752
752
|
'=': value,
|
|
@@ -755,13 +755,24 @@ class PrismaDriver extends BaseDriver
|
|
|
755
755
|
'>=': {gte: value},
|
|
756
756
|
'<': {lt: value},
|
|
757
757
|
'<=': {lte: value},
|
|
758
|
-
'LIKE':
|
|
758
|
+
'LIKE': this.handleLikeOperator(value, fieldName),
|
|
759
759
|
'IN': {in: value},
|
|
760
760
|
'NOT IN': {notIn: value}
|
|
761
761
|
};
|
|
762
762
|
return operatorsMap[operator] || value;
|
|
763
763
|
}
|
|
764
764
|
|
|
765
|
+
handleLikeOperator(value, fieldName)
|
|
766
|
+
{
|
|
767
|
+
if('id' === fieldName || (this.referenceFields && sc.hasOwn(this.referenceFields, fieldName))){
|
|
768
|
+
let numericValue = Number(value.replace(/%/g, ''));
|
|
769
|
+
if(!isNaN(numericValue)){
|
|
770
|
+
return numericValue;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
return {contains: value};
|
|
774
|
+
}
|
|
775
|
+
|
|
765
776
|
buildIncludeObject(relations)
|
|
766
777
|
{
|
|
767
778
|
let include = {};
|