1
1
import anyTest , { TestFn } from 'ava' ;
2
2
import Docker from 'dockerode' ;
3
- import { DefaultLogger , sql } from 'drizzle-orm' ;
3
+ import { sql } from 'drizzle-orm' ;
4
4
import { asc , eq , gt , inArray } from 'drizzle-orm/expressions' ;
5
5
import { drizzle , NodePgDatabase } from 'drizzle-orm/node-postgres' ;
6
6
import { migrate } from 'drizzle-orm/node-postgres/migrator' ;
@@ -9,9 +9,13 @@ import {
9
9
AnyPgColumn ,
10
10
boolean ,
11
11
char ,
12
+ cidr ,
13
+ inet ,
12
14
InferModel ,
13
15
integer ,
14
16
jsonb ,
17
+ macaddr ,
18
+ macaddr8 ,
15
19
pgTable ,
16
20
serial ,
17
21
text ,
@@ -61,6 +65,13 @@ const orders = pgTable('orders', {
61
65
quantity : integer ( 'quantity' ) . notNull ( ) ,
62
66
} ) ;
63
67
68
+ const network = pgTable ( 'network_table' , {
69
+ inet : inet ( 'inet' ) . notNull ( ) ,
70
+ cidr : cidr ( 'cidr' ) . notNull ( ) ,
71
+ macaddr : macaddr ( 'macaddr' ) . notNull ( ) ,
72
+ macaddr8 : macaddr8 ( 'macaddr8' ) . notNull ( ) ,
73
+ } ) ;
74
+
64
75
const usersMigratorTable = pgTable ( 'users12' , {
65
76
id : serial ( 'id' ) . primaryKey ( ) ,
66
77
name : text ( 'name' ) . notNull ( ) ,
@@ -179,6 +190,14 @@ test.beforeEach(async (t) => {
179
190
quantity integer not null
180
191
)` ,
181
192
) ;
193
+ await ctx . db . execute (
194
+ sql `create table network_table (
195
+ inet inet not null,
196
+ cidr cidr not null,
197
+ macaddr macaddr not null,
198
+ macaddr8 macaddr8 not null
199
+ )` ,
200
+ ) ;
182
201
} ) ;
183
202
184
203
test . serial ( 'select all fields' , async ( t ) => {
@@ -1135,6 +1154,23 @@ test.serial('select count w/ custom mapper', async (t) => {
1135
1154
t . deepEqual ( res , [ { count : 2 } ] ) ;
1136
1155
} ) ;
1137
1156
1157
+ test . serial ( 'network types' , async ( t ) => {
1158
+ const { db } = t . context ;
1159
+
1160
+ const value : InferModel < typeof network > = {
1161
+ inet : '127.0.0.1' ,
1162
+ cidr : '192.168.100.128/25' ,
1163
+ macaddr : '08:00:2b:01:02:03' ,
1164
+ macaddr8 : '08:00:2b:01:02:03:04:05' ,
1165
+ } ;
1166
+
1167
+ await db . insert ( network ) . values ( value ) ;
1168
+
1169
+ const res = await db . select ( ) . from ( network ) ;
1170
+
1171
+ t . deepEqual ( res , [ value ] ) ;
1172
+ } ) ;
1173
+
1138
1174
test . after . always ( async ( t ) => {
1139
1175
const ctx = t . context ;
1140
1176
await ctx . client ?. end ( ) . catch ( console . error ) ;
0 commit comments