@@ -23,14 +23,18 @@ describe('mongo data types', () => {
23
23
int2 : 1000 ,
24
24
int4 : 1000000 ,
25
25
int8 : 9007199254740993n ,
26
- float : 3.14
26
+ float : 3.14 ,
27
+ decimal : new mongo . Decimal128 ( '3.14' )
27
28
} ,
28
29
{ _id : 2 as any , nested : { test : 'thing' } } ,
29
30
{ _id : 3 as any , date : new Date ( '2023-03-06 15:47+02' ) } ,
30
31
{
31
32
_id : 4 as any ,
32
33
timestamp : mongo . Timestamp . fromBits ( 123 , 456 ) ,
33
- objectId : mongo . ObjectId . createFromHexString ( '66e834cc91d805df11fa0ecb' )
34
+ objectId : mongo . ObjectId . createFromHexString ( '66e834cc91d805df11fa0ecb' ) ,
35
+ regexp : new mongo . BSONRegExp ( 'test' , 'i' ) ,
36
+ minKey : new mongo . MinKey ( ) ,
37
+ maxKey : new mongo . MaxKey ( )
34
38
}
35
39
] ) ;
36
40
}
@@ -47,14 +51,18 @@ describe('mongo data types', () => {
47
51
int2 : [ 1000 ] ,
48
52
int4 : [ 1000000 ] ,
49
53
int8 : [ 9007199254740993n ] ,
50
- float : [ 3.14 ]
54
+ float : [ 3.14 ] ,
55
+ decimal : [ new mongo . Decimal128 ( '3.14' ) ]
51
56
} ,
52
57
{ _id : 2 as any , nested : [ { test : 'thing' } ] } ,
53
58
{ _id : 3 as any , date : [ new Date ( '2023-03-06 15:47+02' ) ] } ,
54
59
{
55
60
_id : 10 as any ,
56
61
timestamp : [ mongo . Timestamp . fromBits ( 123 , 456 ) ] ,
57
- objectId : [ mongo . ObjectId . createFromHexString ( '66e834cc91d805df11fa0ecb' ) ]
62
+ objectId : [ mongo . ObjectId . createFromHexString ( '66e834cc91d805df11fa0ecb' ) ] ,
63
+ regexp : [ new mongo . BSONRegExp ( 'test' , 'i' ) ] ,
64
+ minKey : [ new mongo . MinKey ( ) ] ,
65
+ maxKey : [ new mongo . MaxKey ( ) ]
58
66
}
59
67
] ) ;
60
68
}
@@ -70,7 +78,8 @@ describe('mongo data types', () => {
70
78
int4 : 1000000n ,
71
79
int8 : 9007199254740993n ,
72
80
float : 3.14 ,
73
- null : null
81
+ null : null ,
82
+ decimal : '3.14'
74
83
} ) ;
75
84
expect ( transformed [ 1 ] ) . toMatchObject ( {
76
85
_id : 2n ,
@@ -85,7 +94,10 @@ describe('mongo data types', () => {
85
94
expect ( transformed [ 3 ] ) . toMatchObject ( {
86
95
_id : 4n ,
87
96
objectId : '66e834cc91d805df11fa0ecb' ,
88
- timestamp : 1958505087099n
97
+ timestamp : 1958505087099n ,
98
+ regexp : '{"pattern":"test","options":"i"}' ,
99
+ minKey : null ,
100
+ maxKey : null
89
101
} ) ;
90
102
}
91
103
@@ -220,21 +232,25 @@ describe('mongo data types', () => {
220
232
const schema = await adapter . getConnectionSchema ( ) ;
221
233
const dbSchema = schema . filter ( ( s ) => s . name == TEST_CONNECTION_OPTIONS . database ) [ 0 ] ;
222
234
expect ( dbSchema ) . not . toBeNull ( ) ;
223
- expect ( dbSchema . tables ) . toEqual ( [
235
+ expect ( dbSchema . tables ) . toMatchObject ( [
224
236
{
225
237
name : 'test_data' ,
226
238
columns : [
227
239
{ name : '_id' , sqlite_type : 4 , internal_type : 'Integer' } ,
228
240
{ name : 'bool' , sqlite_type : 4 , internal_type : 'Boolean' } ,
229
241
{ name : 'bytea' , sqlite_type : 1 , internal_type : 'Binary' } ,
230
242
{ name : 'date' , sqlite_type : 2 , internal_type : 'Date' } ,
243
+ { name : 'decimal' , sqlite_type : 2 , internal_type : 'Decimal' } ,
231
244
{ name : 'float' , sqlite_type : 8 , internal_type : 'Double' } ,
232
245
{ name : 'int2' , sqlite_type : 4 , internal_type : 'Integer' } ,
233
246
{ name : 'int4' , sqlite_type : 4 , internal_type : 'Integer' } ,
234
247
{ name : 'int8' , sqlite_type : 4 , internal_type : 'Long' } ,
248
+ { name : 'maxKey' , sqlite_type : 0 , internal_type : 'MaxKey' } ,
249
+ { name : 'minKey' , sqlite_type : 0 , internal_type : 'MinKey' } ,
235
250
{ name : 'nested' , sqlite_type : 2 , internal_type : 'Object' } ,
236
251
{ name : 'null' , sqlite_type : 0 , internal_type : 'Null' } ,
237
252
{ name : 'objectId' , sqlite_type : 2 , internal_type : 'ObjectId' } ,
253
+ { name : 'regexp' , sqlite_type : 2 , internal_type : 'RegExp' } ,
238
254
{ name : 'text' , sqlite_type : 2 , internal_type : 'String' } ,
239
255
{ name : 'timestamp' , sqlite_type : 4 , internal_type : 'Timestamp' } ,
240
256
{ name : 'uuid' , sqlite_type : 2 , internal_type : 'UUID' }
0 commit comments