@@ -5,15 +5,22 @@ import {
55 bigserial ,
66 boolean ,
77 char ,
8+ cidr ,
89 date ,
910 doublePrecision ,
11+ geometry ,
12+ inet ,
1013 integer ,
14+ interval ,
1115 json ,
1216 jsonb ,
17+ line ,
18+ macaddr ,
1319 numeric ,
1420 pgEnum ,
1521 pgSchema ,
1622 pgTable ,
23+ point ,
1724 primaryKey ,
1825 real ,
1926 serial ,
@@ -180,24 +187,6 @@ describe.concurrent("tables", () => {
180187 Expect < Equal < typeof result , typeof expected > > ;
181188 } ) ;
182189
183- test ( "pg - array types" , ( ) => {
184- const table = pgTable ( "test" , {
185- id : text ( ) . primaryKey ( ) ,
186- tags : text ( ) . array ( ) . notNull ( ) ,
187- scores : jsonb ( ) . array ( ) ,
188- } ) ;
189-
190- expect ( ( ) =>
191- createZeroTableSchema ( table , {
192- id : true ,
193- tags : true ,
194- scores : true ,
195- } ) ,
196- ) . toThrowErrorMatchingInlineSnapshot (
197- `[Error: drizzle-zero: Unsupported column type: array. It must be supported by Zero, e.g.: number | bigint | boolean | date | string | json]` ,
198- ) ;
199- } ) ;
200-
201190 test ( "pg - complex custom types" , ( ) => {
202191 type UserMetadata = {
203192 preferences : {
@@ -1225,6 +1214,22 @@ describe.concurrent("tables", () => {
12251214 Expect < Equal < typeof result , typeof expected > > ;
12261215 } ) ;
12271216
1217+ test ( "pg - invalid column type" , ( ) => {
1218+ const table = pgTable ( "test" , {
1219+ id : text ( ) . primaryKey ( ) ,
1220+ invalid : text ( ) . notNull ( ) ,
1221+ } ) ;
1222+
1223+ expect ( ( ) =>
1224+ createZeroTableSchema ( table , {
1225+ id : true ,
1226+ invalid : "someinvalidtype" ,
1227+ } as unknown as ColumnsConfig < typeof table > ) ,
1228+ ) . toThrowErrorMatchingInlineSnapshot (
1229+ `[Error: drizzle-zero: Invalid column config for column invalid - expected boolean or object but was string]` ,
1230+ ) ;
1231+ } ) ;
1232+
12281233 test ( "pg - invalid column selection" , ( ) => {
12291234 const table = pgTable ( "test" , {
12301235 id : text ( ) . primaryKey ( ) ,
@@ -1241,6 +1246,140 @@ describe.concurrent("tables", () => {
12411246 ) ;
12421247 } ) ;
12431248
1249+ test ( "pg - array types" , ( ) => {
1250+ const table = pgTable ( "test" , {
1251+ id : text ( ) . primaryKey ( ) ,
1252+ tags : text ( ) . array ( ) . notNull ( ) ,
1253+ scores : jsonb ( ) . array ( ) ,
1254+ } ) ;
1255+
1256+ expect ( ( ) =>
1257+ createZeroTableSchema ( table , {
1258+ id : true ,
1259+ tags : true ,
1260+ scores : true ,
1261+ } ) ,
1262+ ) . toThrowErrorMatchingInlineSnapshot (
1263+ `[Error: drizzle-zero: Unsupported column type: PgArray (array). It must be supported by Zero, e.g.: number | bigint | boolean | date | PgText | PgChar | PgVarchar | PgUUID | PgEnumColumn | PgJsonb | PgJson | PgNumeric | PgDateString | PgTimestampString]` ,
1264+ ) ;
1265+ } ) ;
1266+
1267+ test ( "pg - interval types" , ( ) => {
1268+ const table = pgTable ( "test" , {
1269+ id : text ( ) . primaryKey ( ) ,
1270+ interval : interval ( ) . notNull ( ) ,
1271+ } ) ;
1272+
1273+ expect ( ( ) =>
1274+ createZeroTableSchema ( table , {
1275+ id : true ,
1276+ interval : true ,
1277+ } ) ,
1278+ ) . toThrowErrorMatchingInlineSnapshot (
1279+ `[Error: drizzle-zero: Unsupported column type: PgInterval (string). It must be supported by Zero, e.g.: number | bigint | boolean | date | PgText | PgChar | PgVarchar | PgUUID | PgEnumColumn | PgJsonb | PgJson | PgNumeric | PgDateString | PgTimestampString]` ,
1280+ ) ;
1281+ } ) ;
1282+
1283+ test ( "pg - cidr types" , ( ) => {
1284+ const table = pgTable ( "test" , {
1285+ id : text ( ) . primaryKey ( ) ,
1286+ cidr : cidr ( ) . notNull ( ) ,
1287+ } ) ;
1288+
1289+ expect ( ( ) =>
1290+ createZeroTableSchema ( table , {
1291+ id : true ,
1292+ cidr : true ,
1293+ } ) ,
1294+ ) . toThrowErrorMatchingInlineSnapshot (
1295+ `[Error: drizzle-zero: Unsupported column type: PgCidr (string). It must be supported by Zero, e.g.: number | bigint | boolean | date | PgText | PgChar | PgVarchar | PgUUID | PgEnumColumn | PgJsonb | PgJson | PgNumeric | PgDateString | PgTimestampString]` ,
1296+ ) ;
1297+ } ) ;
1298+
1299+ test ( "pg - macaddr types" , ( ) => {
1300+ const table = pgTable ( "test" , {
1301+ id : text ( ) . primaryKey ( ) ,
1302+ macaddr : macaddr ( ) . notNull ( ) ,
1303+ } ) ;
1304+
1305+ expect ( ( ) =>
1306+ createZeroTableSchema ( table , {
1307+ id : true ,
1308+ macaddr : true ,
1309+ } ) ,
1310+ ) . toThrowErrorMatchingInlineSnapshot (
1311+ `[Error: drizzle-zero: Unsupported column type: PgMacaddr (string). It must be supported by Zero, e.g.: number | bigint | boolean | date | PgText | PgChar | PgVarchar | PgUUID | PgEnumColumn | PgJsonb | PgJson | PgNumeric | PgDateString | PgTimestampString]` ,
1312+ ) ;
1313+ } ) ;
1314+
1315+ test ( "pg - inet types" , ( ) => {
1316+ const table = pgTable ( "test" , {
1317+ id : text ( ) . primaryKey ( ) ,
1318+ inet : inet ( ) . notNull ( ) ,
1319+ } ) ;
1320+
1321+ expect ( ( ) =>
1322+ createZeroTableSchema ( table , {
1323+ id : true ,
1324+ inet : true ,
1325+ } ) ,
1326+ ) . toThrowErrorMatchingInlineSnapshot (
1327+ `[Error: drizzle-zero: Unsupported column type: PgInet (string). It must be supported by Zero, e.g.: number | bigint | boolean | date | PgText | PgChar | PgVarchar | PgUUID | PgEnumColumn | PgJsonb | PgJson | PgNumeric | PgDateString | PgTimestampString]` ,
1328+ ) ;
1329+ } ) ;
1330+
1331+ test ( "pg - point types" , ( ) => {
1332+ const table = pgTable ( "test" , {
1333+ id : text ( ) . primaryKey ( ) ,
1334+ point : point ( ) . notNull ( ) ,
1335+ } ) ;
1336+
1337+ expect ( ( ) =>
1338+ createZeroTableSchema ( table , {
1339+ id : true ,
1340+ point : true ,
1341+ } ) ,
1342+ ) . toThrowErrorMatchingInlineSnapshot (
1343+ `[Error: drizzle-zero: Unsupported column type: PgPointTuple (array). It must be supported by Zero, e.g.: number | bigint | boolean | date | PgText | PgChar | PgVarchar | PgUUID | PgEnumColumn | PgJsonb | PgJson | PgNumeric | PgDateString | PgTimestampString]` ,
1344+ ) ;
1345+ } ) ;
1346+
1347+ test ( "pg - line types" , ( ) => {
1348+ const table = pgTable ( "test" , {
1349+ id : text ( ) . primaryKey ( ) ,
1350+ line : line ( ) . notNull ( ) ,
1351+ } ) ;
1352+
1353+ expect ( ( ) =>
1354+ createZeroTableSchema ( table , {
1355+ id : true ,
1356+ line : true ,
1357+ } ) ,
1358+ ) . toThrowErrorMatchingInlineSnapshot (
1359+ `[Error: drizzle-zero: Unsupported column type: PgLine (array). It must be supported by Zero, e.g.: number | bigint | boolean | date | PgText | PgChar | PgVarchar | PgUUID | PgEnumColumn | PgJsonb | PgJson | PgNumeric | PgDateString | PgTimestampString]` ,
1360+ ) ;
1361+ } ) ;
1362+
1363+ test ( "pg - geometry types" , ( ) => {
1364+ const table = pgTable ( "test" , {
1365+ id : text ( ) . primaryKey ( ) ,
1366+ location : geometry ( "location" , {
1367+ type : "point" ,
1368+ mode : "xy" ,
1369+ srid : 4326 ,
1370+ } ) . notNull ( ) ,
1371+ } ) ;
1372+
1373+ expect ( ( ) =>
1374+ createZeroTableSchema ( table , {
1375+ id : true ,
1376+ location : true ,
1377+ } ) ,
1378+ ) . toThrowErrorMatchingInlineSnapshot (
1379+ `[Error: drizzle-zero: Unsupported column type: PgGeometryObject (json). It must be supported by Zero, e.g.: number | bigint | boolean | date | PgText | PgChar | PgVarchar | PgUUID | PgEnumColumn | PgJsonb | PgJson | PgNumeric | PgDateString | PgTimestampString]` ,
1380+ ) ;
1381+ } ) ;
1382+
12441383 test ( "pg - no primary key" , ( ) => {
12451384 const table = pgTable ( "test" , {
12461385 id : text ( ) ,
0 commit comments