Skip to content

Commit fce5ad3

Browse files
authored
fix: cast numbers in DataTypes.STRING to strings (#17564)
1 parent 78a9733 commit fce5ad3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/dialects/abstract/query-generator.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,12 @@ class QueryGenerator {
11041104
return this.handleSequelizeMethod(value);
11051105
}
11061106
if (field && field.type) {
1107+
if (field.type instanceof DataTypes.STRING
1108+
&& ['mysql', 'mariadb'].includes(this.dialect)
1109+
&& ['number', 'boolean'].includes(typeof value)) {
1110+
value = String(Number(value));
1111+
}
1112+
11071113
this.validate(value, field, options);
11081114

11091115
if (field.type.stringify) {

0 commit comments

Comments
 (0)