Skip to content

Commit 71a1be6

Browse files
committed
fix: column data not consistent across all dbms (#108)
fix: regexp in model attr set function
1 parent 7c897ae commit 71a1be6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/packages/database/model/utils/initialize.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,10 @@ function initializeProps(prototype, attributes, relationships) {
9393
if (nextValue !== currentValue) {
9494
const { initialized, initialValues } = this;
9595

96-
if (type === 'tinyint') {
96+
if (/^(boolean|tinyint)$/.test(type)) {
9797
nextValue = Boolean(nextValue);
98+
} else if (type === 'datetime' && typeof nextValue === 'number') {
99+
nextValue = new Date(nextValue);
98100
} else if (!nextValue && !nullable) {
99101
return;
100102
}

0 commit comments

Comments
 (0)