@@ -69,6 +69,7 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
69
69
return Number . isInteger ( value ) ? 'integer' : 'float' ;
70
70
}
71
71
if ( value instanceof Date ) return 'datetime' ;
72
+ if ( value && typeof value === 'object' && ( '$numberDecimal' in value || value . _bsontype === 'Decimal128' ) ) return 'decimal' ;
72
73
if ( typeof value === 'object' ) return 'json' ;
73
74
return 'string' ;
74
75
}
@@ -89,13 +90,18 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
89
90
sampleValues . set ( fullKey , value ) ;
90
91
}
91
92
92
- if (
93
- value instanceof Buffer ||
94
- ( value && typeof value === 'object' && ( value as any ) . _bsontype === 'Decimal128' )
95
- ) {
93
+ if ( value instanceof Buffer ) {
96
94
addType ( fullKey , 'json' ) ;
97
95
return ;
98
96
}
97
+ if (
98
+ value &&
99
+ typeof value === 'object' &&
100
+ ( '$numberDecimal' in value || value . _bsontype === 'Decimal128' )
101
+ ) {
102
+ addType ( fullKey , 'decimal' ) ;
103
+ return ;
104
+ }
99
105
100
106
if (
101
107
value &&
@@ -104,9 +110,10 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
104
110
! ( value instanceof Date )
105
111
) {
106
112
addType ( fullKey , 'json' ) ;
107
- } else {
108
- addType ( fullKey , detectType ( value ) ) ;
113
+ return
109
114
}
115
+
116
+ addType ( fullKey , detectType ( value ) ) ;
110
117
} ) ;
111
118
}
112
119
@@ -117,7 +124,7 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
117
124
return Array . from ( fieldTypes . entries ( ) ) . map ( ( [ name , types ] ) => {
118
125
const primaryKey = name === '_id' ;
119
126
120
- const priority = [ 'datetime' , 'date' , 'integer' , 'float' , 'boolean' , 'json' , 'string' ] ;
127
+ const priority = [ 'datetime' , 'date' , 'integer' , 'float' , 'boolean' , 'json' , 'decimal' , ' string'] ;
121
128
122
129
const matched = priority . find ( t => types . has ( t ) ) || 'string' ;
123
130
@@ -129,8 +136,8 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
129
136
datetime : 'DATETIME' ,
130
137
date : 'DATE' ,
131
138
json : 'JSON' ,
139
+ decimal : 'DECIMAL' ,
132
140
} ;
133
-
134
141
return {
135
142
name,
136
143
type : typeMap [ matched ] ?? 'STRING' ,
0 commit comments