befly 3.9.0 → 3.9.1
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.1",
|
|
4
4
|
"description": "Befly - 为 Bun 专属打造的 TypeScript API 接口框架核心引擎",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"pino": "^10.1.0",
|
|
74
74
|
"pino-roll": "^4.0.0"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "506400b7cc501bc1d4be3c2af76f2275172dacd8",
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"typescript": "^5.9.3"
|
|
79
79
|
}
|
package/sync/syncDb/types.ts
CHANGED
|
@@ -65,8 +65,9 @@ export function getSqlType(fieldType: string, fieldMax: number | null, unsigned:
|
|
|
65
65
|
* resolveDefaultValue(null, 'string') // => ''
|
|
66
66
|
* resolveDefaultValue(null, 'number') // => 0
|
|
67
67
|
* resolveDefaultValue('null', 'number') // => 0
|
|
68
|
-
* resolveDefaultValue(null, '
|
|
68
|
+
* resolveDefaultValue(null, 'array_string') // => '[]'
|
|
69
69
|
* resolveDefaultValue(null, 'text') // => 'null'
|
|
70
|
+
* resolveDefaultValue(null, 'array_text') // => 'null' (TEXT 不支持默认值)
|
|
70
71
|
* resolveDefaultValue('admin', 'string') // => 'admin'
|
|
71
72
|
* resolveDefaultValue(0, 'number') // => 0
|
|
72
73
|
*/
|
|
@@ -82,12 +83,11 @@ export function resolveDefaultValue(fieldDefault: any, fieldType: string): any {
|
|
|
82
83
|
return 0;
|
|
83
84
|
case 'string':
|
|
84
85
|
return '';
|
|
85
|
-
case 'array':
|
|
86
86
|
case 'array_string':
|
|
87
|
-
case 'array_text':
|
|
88
87
|
return '[]';
|
|
89
88
|
case 'text':
|
|
90
|
-
|
|
89
|
+
case 'array_text':
|
|
90
|
+
// text/array_text 类型不设置默认值(MySQL TEXT 不支持),保持 'null'
|
|
91
91
|
return 'null';
|
|
92
92
|
default:
|
|
93
93
|
return fieldDefault;
|
|
@@ -63,14 +63,18 @@ describe('resolveDefaultValue', () => {
|
|
|
63
63
|
expect(resolveDefaultValue('null', 'number')).toBe(0);
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
test('null 值 +
|
|
67
|
-
expect(resolveDefaultValue(null, '
|
|
66
|
+
test('null 值 + array_string 类型 => "[]"', () => {
|
|
67
|
+
expect(resolveDefaultValue(null, 'array_string')).toBe('[]');
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
test('null 值 + text 类型 => "null"', () => {
|
|
71
71
|
expect(resolveDefaultValue(null, 'text')).toBe('null');
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
+
test('null 值 + array_text 类型 => "null"(TEXT 不支持默认值)', () => {
|
|
75
|
+
expect(resolveDefaultValue(null, 'array_text')).toBe('null');
|
|
76
|
+
});
|
|
77
|
+
|
|
74
78
|
test('有实际值时直接返回', () => {
|
|
75
79
|
expect(resolveDefaultValue('admin', 'string')).toBe('admin');
|
|
76
80
|
expect(resolveDefaultValue(100, 'number')).toBe(100);
|