@@ -6,13 +6,7 @@ describe('cast', () => {
6
6
cast (
7
7
{
8
8
name : 'email' ,
9
- type : 'VARCHAR' ,
10
- table : 'users' ,
11
- orgTable : 'users' ,
12
- database : 'database-js' ,
13
- orgName : 'email' ,
14
- columnLength : 1020 ,
15
- charset : 255
9
+ type : 'VARCHAR'
16
10
} ,
17
11
null
18
12
)
@@ -24,72 +18,43 @@ describe('cast', () => {
24
18
cast (
25
19
{
26
20
name : 'id' ,
27
- type : 'UINT64' ,
28
- table : 'users' ,
29
- orgTable : 'users' ,
30
- database : 'database-js' ,
31
- orgName : 'id' ,
32
- columnLength : 20 ,
33
- charset : 63 ,
34
- flags : 49699
21
+ type : 'UINT64'
35
22
} ,
36
23
'1'
37
24
)
38
25
) . toEqual ( '1' )
39
26
} )
40
27
41
- test ( 'casts DECIMAL values' , ( ) => {
28
+ test ( 'casts DATETIME, DATE, TIMESTAMP, TIME values' , ( ) => {
42
29
expect (
43
30
cast (
44
31
{
45
- name : 'decimal' ,
46
- type : 'DECIMAL' ,
47
- table : 'decimals' ,
48
- orgTable : 'decimals' ,
49
- database : 'blob' ,
50
- orgName : 'decimal' ,
51
- columnLength : 12 ,
52
- charset : 63 ,
53
- decimals : 2 ,
54
- flags : 32768
32
+ name : 'created_at' ,
33
+ type : 'DATETIME'
55
34
} ,
56
- '5.4 '
35
+ '2024-01-01 00:00:00 '
57
36
)
58
- ) . toEqual ( '5.4 ' )
37
+ ) . toEqual ( '2024-01-01 00:00:00 ' )
59
38
} )
60
39
61
- test ( 'casts DATETIME, DATE, TIMESTAMP, TIME values' , ( ) => {
40
+ test ( 'casts DECIMAL values' , ( ) => {
62
41
expect (
63
42
cast (
64
43
{
65
- name : 'created_at' ,
66
- type : 'DATETIME' ,
67
- table : 'users' ,
68
- orgTable : 'users' ,
69
- database : 'database-js' ,
70
- orgName : 'created_at' ,
71
- columnLength : 19 ,
72
- charset : 63 ,
73
- flags : 128
44
+ name : 'decimal' ,
45
+ type : 'DECIMAL'
74
46
} ,
75
- '2024-01-01 00:00:00 '
47
+ '5.4 '
76
48
)
77
- ) . toEqual ( '2024-01-01 00:00:00 ' )
49
+ ) . toEqual ( '5.4 ' )
78
50
} )
79
51
80
52
test ( 'casts JSON values' , ( ) => {
81
53
expect (
82
54
cast (
83
55
{
84
56
name : 'metadata' ,
85
- type : 'JSON' ,
86
- table : 'users' ,
87
- orgTable : 'users' ,
88
- database : 'database-js' ,
89
- orgName : 'metadata' ,
90
- columnLength : 4294967295 ,
91
- charset : 63 ,
92
- flags : 144
57
+ type : 'JSON'
93
58
} ,
94
59
'{ "color": "blue" }'
95
60
)
@@ -101,14 +66,7 @@ describe('cast', () => {
101
66
cast (
102
67
{
103
68
name : 'verified' ,
104
- type : 'INT8' ,
105
- table : 'users' ,
106
- orgTable : 'users' ,
107
- database : 'database-js' ,
108
- orgName : 'verified' ,
109
- columnLength : 1 ,
110
- charset : 63 ,
111
- flags : 32768
69
+ type : 'INT8'
112
70
} ,
113
71
'1'
114
72
)
@@ -117,14 +75,7 @@ describe('cast', () => {
117
75
cast (
118
76
{
119
77
name : 'age' ,
120
- type : 'INT32' ,
121
- table : 'users' ,
122
- orgTable : 'users' ,
123
- database : 'database-js' ,
124
- orgName : 'age' ,
125
- columnLength : 11 ,
126
- charset : 63 ,
127
- flags : 32768
78
+ type : 'INT32'
128
79
} ,
129
80
'21'
130
81
)
@@ -136,15 +87,7 @@ describe('cast', () => {
136
87
cast (
137
88
{
138
89
name : 'float' ,
139
- type : 'FLOAT32' ,
140
- table : 'decimals' ,
141
- orgTable : 'decimals' ,
142
- database : 'blob' ,
143
- orgName : 'float' ,
144
- columnLength : 12 ,
145
- charset : 63 ,
146
- decimals : 31 ,
147
- flags : 32768
90
+ type : 'FLOAT32'
148
91
} ,
149
92
'20.4'
150
93
)
@@ -153,91 +96,30 @@ describe('cast', () => {
153
96
cast (
154
97
{
155
98
name : 'double' ,
156
- type : 'FLOAT64' ,
157
- table : 'decimals' ,
158
- orgTable : 'decimals' ,
159
- database : 'blob' ,
160
- orgName : 'double' ,
161
- columnLength : 22 ,
162
- charset : 63 ,
163
- decimals : 31 ,
164
- flags : 32768
99
+ type : 'FLOAT64'
165
100
} ,
166
101
'101.4'
167
102
)
168
103
) . toEqual ( 101.4 )
169
104
} )
170
105
171
- test ( 'casts VARCHAR values' , ( ) => {
172
- expect (
173
- cast (
174
- {
175
- name : 'email' ,
176
- type : 'VARCHAR' ,
177
- table : 'users' ,
178
- orgTable : 'users' ,
179
- database : 'database-js' ,
180
- orgName : 'email' ,
181
- columnLength : 1020 ,
182
- charset : 255
183
- } ,
184
-
185
- )
186
-
187
- } )
188
-
189
106
test ( 'casts BLOB, BIT, GEOMETRY, BINARY, VARBINARY values' , ( ) => {
190
- /** See e2e tests for more complete assertions */
191
-
192
- expect (
193
- cast (
194
- {
195
- name : 'bytes' ,
196
- type : 'BLOB' ,
197
- table : 'binary_test' ,
198
- orgTable : 'binary_test' ,
199
- database : 'database-js' ,
200
- orgName : 'bytes' ,
201
- columnLength : 4294967295 ,
202
- charset : 63 ,
203
- flags : 4241
204
- } ,
205
- '\u0001\u0002\u0003'
206
- )
207
- ) . toEqual ( new Uint8Array ( [ 1 , 2 , 3 ] ) )
107
+ /** See e2e tests. */
208
108
} )
209
109
210
110
test ( 'casts BINARY, VARBINARY string values' , ( ) => {
211
- /** See e2e tests for more complete assertions */
111
+ /** See e2e tests. */
112
+ } )
212
113
114
+ test ( 'casts VARCHAR values' , ( ) => {
213
115
expect (
214
116
cast (
215
117
{
216
- name : 'Index_type' ,
217
- type : 'VARBINARY' ,
218
- table : 'SHOW_STATISTICS' ,
219
- orgName : 'Index_type' ,
220
- columnLength : 44 ,
221
- charset : 255 ,
222
- flags : 129
223
- } ,
224
- 'BTREE'
225
- )
226
- ) . toEqual ( 'BTREE' )
227
- expect (
228
- cast (
229
- {
230
- name : 'Tables_in_users' ,
231
- type : 'VARBINARY' ,
232
- table : 'TABLES' ,
233
- orgTable : 'tables' ,
234
- orgName : 'Tables_in_users' ,
235
- columnLength : 256 ,
236
- charset : 255 ,
237
- flags : 4225
118
+ name : 'email' ,
119
+ type : 'VARCHAR'
238
120
} ,
239
- 'users '
121
+
240
122
)
241
- ) . toEqual ( 'users ' )
123
+
242
124
} )
243
125
} )
0 commit comments