@dbml/connector 5.0.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/connectors/mssql/expect-out-files/schema.json +238 -113
- package/__tests__/connectors/mysql/expect-out-files/schema.json +132 -2
- package/__tests__/connectors/postgres/expect-out-files/schema.json +219 -8
- package/dist/connectors/bigqueryConnector.js +5 -4
- package/dist/connectors/mssqlConnector.js +82 -149
- package/dist/connectors/mysqlConnector.js +67 -8
- package/dist/connectors/postgresConnector.d.ts +1 -1
- package/dist/connectors/postgresConnector.js +115 -42
- package/dist/connectors/snowflakeConnector.js +8 -6
- package/dist/connectors/types.d.ts +10 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -7
- package/dist/utils/helpers.d.ts +2 -1
- package/dist/utils/helpers.js +14 -3
- package/dist/utils/parseSchema.d.ts +1 -1
- package/dist/utils/parseSchema.js +13 -13
- package/eslint.config.ts +70 -0
- package/jest.config.ts +2 -2
- package/package.json +15 -6
- package/src/connectors/bigqueryConnector.ts +5 -4
- package/src/connectors/mssqlConnector.ts +92 -162
- package/src/connectors/mysqlConnector.ts +77 -12
- package/src/connectors/postgresConnector.ts +126 -44
- package/src/connectors/snowflakeConnector.ts +24 -19
- package/src/connectors/types.ts +20 -65
- package/src/index.ts +1 -1
- package/src/utils/helpers.ts +30 -12
- package/src/utils/parseSchema.ts +11 -11
- package/test-output.log +18 -0
- package/tsconfig.json +1 -1
- package/.eslintrc.json +0 -24
|
@@ -72,6 +72,12 @@
|
|
|
72
72
|
"value": ""
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
|
+
{
|
|
76
|
+
"name": "table_with_composite_primary_and_unique_indexes",
|
|
77
|
+
"note": {
|
|
78
|
+
"value": ""
|
|
79
|
+
}
|
|
80
|
+
},
|
|
75
81
|
{
|
|
76
82
|
"name": "users",
|
|
77
83
|
"note": {
|
|
@@ -882,6 +888,60 @@
|
|
|
882
888
|
}
|
|
883
889
|
}
|
|
884
890
|
],
|
|
891
|
+
"table_with_composite_primary_and_unique_indexes": [
|
|
892
|
+
{
|
|
893
|
+
"name": "col1",
|
|
894
|
+
"type": {
|
|
895
|
+
"type_name": "int",
|
|
896
|
+
"schemaName": null
|
|
897
|
+
},
|
|
898
|
+
"dbdefault": null,
|
|
899
|
+
"not_null": true,
|
|
900
|
+
"increment": false,
|
|
901
|
+
"note": {
|
|
902
|
+
"value": ""
|
|
903
|
+
}
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
"name": "col2",
|
|
907
|
+
"type": {
|
|
908
|
+
"type_name": "int",
|
|
909
|
+
"schemaName": null
|
|
910
|
+
},
|
|
911
|
+
"dbdefault": null,
|
|
912
|
+
"not_null": true,
|
|
913
|
+
"increment": false,
|
|
914
|
+
"note": {
|
|
915
|
+
"value": ""
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
"name": "col3",
|
|
920
|
+
"type": {
|
|
921
|
+
"type_name": "int",
|
|
922
|
+
"schemaName": null
|
|
923
|
+
},
|
|
924
|
+
"dbdefault": null,
|
|
925
|
+
"not_null": false,
|
|
926
|
+
"increment": false,
|
|
927
|
+
"note": {
|
|
928
|
+
"value": ""
|
|
929
|
+
}
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
"name": "col4",
|
|
933
|
+
"type": {
|
|
934
|
+
"type_name": "int",
|
|
935
|
+
"schemaName": null
|
|
936
|
+
},
|
|
937
|
+
"dbdefault": null,
|
|
938
|
+
"not_null": false,
|
|
939
|
+
"increment": false,
|
|
940
|
+
"note": {
|
|
941
|
+
"value": ""
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
],
|
|
885
945
|
"users": [
|
|
886
946
|
{
|
|
887
947
|
"name": "user_id",
|
|
@@ -1297,7 +1357,7 @@
|
|
|
1297
1357
|
"composite_key_1": [
|
|
1298
1358
|
{
|
|
1299
1359
|
"name": "PRIMARY",
|
|
1300
|
-
"
|
|
1360
|
+
"pk": true,
|
|
1301
1361
|
"columns": [
|
|
1302
1362
|
{
|
|
1303
1363
|
"type": "column",
|
|
@@ -1327,7 +1387,7 @@
|
|
|
1327
1387
|
"composite_key_2": [
|
|
1328
1388
|
{
|
|
1329
1389
|
"name": "PRIMARY",
|
|
1330
|
-
"
|
|
1390
|
+
"pk": true,
|
|
1331
1391
|
"columns": [
|
|
1332
1392
|
{
|
|
1333
1393
|
"type": "column",
|
|
@@ -1339,52 +1399,122 @@
|
|
|
1339
1399
|
}
|
|
1340
1400
|
]
|
|
1341
1401
|
}
|
|
1402
|
+
],
|
|
1403
|
+
"table_with_composite_primary_and_unique_indexes": [
|
|
1404
|
+
{
|
|
1405
|
+
"name": "col3",
|
|
1406
|
+
"unique": true,
|
|
1407
|
+
"columns": [
|
|
1408
|
+
{
|
|
1409
|
+
"type": "column",
|
|
1410
|
+
"value": "col3"
|
|
1411
|
+
},
|
|
1412
|
+
{
|
|
1413
|
+
"type": "column",
|
|
1414
|
+
"value": "col4"
|
|
1415
|
+
}
|
|
1416
|
+
]
|
|
1417
|
+
},
|
|
1418
|
+
{
|
|
1419
|
+
"name": "PRIMARY",
|
|
1420
|
+
"pk": true,
|
|
1421
|
+
"columns": [
|
|
1422
|
+
{
|
|
1423
|
+
"type": "column",
|
|
1424
|
+
"value": "col1"
|
|
1425
|
+
},
|
|
1426
|
+
{
|
|
1427
|
+
"type": "column",
|
|
1428
|
+
"value": "col2"
|
|
1429
|
+
}
|
|
1430
|
+
]
|
|
1431
|
+
}
|
|
1342
1432
|
]
|
|
1343
1433
|
},
|
|
1344
1434
|
"tableConstraints": {
|
|
1345
1435
|
"categories": {
|
|
1346
1436
|
"cat_id": {
|
|
1437
|
+
"checks": [],
|
|
1347
1438
|
"pk": true
|
|
1348
1439
|
}
|
|
1349
1440
|
},
|
|
1350
1441
|
"default_example": {
|
|
1351
1442
|
"id": {
|
|
1443
|
+
"checks": [],
|
|
1352
1444
|
"pk": true
|
|
1353
1445
|
}
|
|
1354
1446
|
},
|
|
1355
1447
|
"hash_index_example": {
|
|
1356
1448
|
"id": {
|
|
1449
|
+
"checks": [],
|
|
1357
1450
|
"pk": true
|
|
1358
1451
|
}
|
|
1359
1452
|
},
|
|
1360
1453
|
"index_example": {
|
|
1361
1454
|
"email": {
|
|
1455
|
+
"checks": [],
|
|
1362
1456
|
"unique": true
|
|
1363
1457
|
},
|
|
1364
1458
|
"id": {
|
|
1459
|
+
"checks": [],
|
|
1365
1460
|
"pk": true
|
|
1366
1461
|
}
|
|
1367
1462
|
},
|
|
1368
1463
|
"orders": {
|
|
1369
1464
|
"order_id": {
|
|
1465
|
+
"checks": [],
|
|
1370
1466
|
"pk": true
|
|
1371
1467
|
}
|
|
1372
1468
|
},
|
|
1373
1469
|
"products": {
|
|
1374
1470
|
"id": {
|
|
1471
|
+
"checks": [],
|
|
1375
1472
|
"pk": true
|
|
1473
|
+
},
|
|
1474
|
+
"total_value": {
|
|
1475
|
+
"checks": [
|
|
1476
|
+
{
|
|
1477
|
+
"name": "products_chk_2",
|
|
1478
|
+
"expression": "`total_value` > 0"
|
|
1479
|
+
}
|
|
1480
|
+
]
|
|
1481
|
+
},
|
|
1482
|
+
"quantity": {
|
|
1483
|
+
"checks": [
|
|
1484
|
+
{
|
|
1485
|
+
"name": "max_quantity",
|
|
1486
|
+
"expression": "`quantity` < 10000"
|
|
1487
|
+
}
|
|
1488
|
+
]
|
|
1376
1489
|
}
|
|
1377
1490
|
},
|
|
1378
1491
|
"users": {
|
|
1379
1492
|
"email": {
|
|
1493
|
+
"checks": [],
|
|
1380
1494
|
"unique": true
|
|
1381
1495
|
},
|
|
1382
1496
|
"user_id": {
|
|
1497
|
+
"checks": [],
|
|
1383
1498
|
"pk": true
|
|
1384
1499
|
},
|
|
1385
1500
|
"username": {
|
|
1501
|
+
"checks": [],
|
|
1386
1502
|
"unique": true
|
|
1387
1503
|
}
|
|
1388
1504
|
}
|
|
1505
|
+
},
|
|
1506
|
+
"checks": {
|
|
1507
|
+
"users": [
|
|
1508
|
+
{
|
|
1509
|
+
"name": "chk_last_login",
|
|
1510
|
+
"expression": "`created_at` <= `last_login`"
|
|
1511
|
+
}
|
|
1512
|
+
],
|
|
1513
|
+
"products": [
|
|
1514
|
+
{
|
|
1515
|
+
"name": "products_chk_1",
|
|
1516
|
+
"expression": "(`price` > 0) and (`price` < 1000000)"
|
|
1517
|
+
}
|
|
1518
|
+
]
|
|
1389
1519
|
}
|
|
1390
1520
|
}
|
|
@@ -97,6 +97,13 @@
|
|
|
97
97
|
"note": {
|
|
98
98
|
"value": ""
|
|
99
99
|
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"name": "table_with_composite_primary_and_unique_indexes",
|
|
103
|
+
"schemaName": "public",
|
|
104
|
+
"note": {
|
|
105
|
+
"value": ""
|
|
106
|
+
}
|
|
100
107
|
}
|
|
101
108
|
],
|
|
102
109
|
"fields": {
|
|
@@ -1270,6 +1277,60 @@
|
|
|
1270
1277
|
"value": ""
|
|
1271
1278
|
}
|
|
1272
1279
|
}
|
|
1280
|
+
],
|
|
1281
|
+
"public.table_with_composite_primary_and_unique_indexes": [
|
|
1282
|
+
{
|
|
1283
|
+
"name": "col1",
|
|
1284
|
+
"type": {
|
|
1285
|
+
"type_name": "int4",
|
|
1286
|
+
"schemaName": null
|
|
1287
|
+
},
|
|
1288
|
+
"dbdefault": null,
|
|
1289
|
+
"not_null": true,
|
|
1290
|
+
"increment": false,
|
|
1291
|
+
"note": {
|
|
1292
|
+
"value": ""
|
|
1293
|
+
}
|
|
1294
|
+
},
|
|
1295
|
+
{
|
|
1296
|
+
"name": "col2",
|
|
1297
|
+
"type": {
|
|
1298
|
+
"type_name": "int4",
|
|
1299
|
+
"schemaName": null
|
|
1300
|
+
},
|
|
1301
|
+
"dbdefault": null,
|
|
1302
|
+
"not_null": true,
|
|
1303
|
+
"increment": false,
|
|
1304
|
+
"note": {
|
|
1305
|
+
"value": ""
|
|
1306
|
+
}
|
|
1307
|
+
},
|
|
1308
|
+
{
|
|
1309
|
+
"name": "col3",
|
|
1310
|
+
"type": {
|
|
1311
|
+
"type_name": "int4",
|
|
1312
|
+
"schemaName": null
|
|
1313
|
+
},
|
|
1314
|
+
"dbdefault": null,
|
|
1315
|
+
"not_null": false,
|
|
1316
|
+
"increment": false,
|
|
1317
|
+
"note": {
|
|
1318
|
+
"value": ""
|
|
1319
|
+
}
|
|
1320
|
+
},
|
|
1321
|
+
{
|
|
1322
|
+
"name": "col4",
|
|
1323
|
+
"type": {
|
|
1324
|
+
"type_name": "int4",
|
|
1325
|
+
"schemaName": null
|
|
1326
|
+
},
|
|
1327
|
+
"dbdefault": null,
|
|
1328
|
+
"not_null": false,
|
|
1329
|
+
"increment": false,
|
|
1330
|
+
"note": {
|
|
1331
|
+
"value": ""
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1273
1334
|
]
|
|
1274
1335
|
},
|
|
1275
1336
|
"refs": [
|
|
@@ -1447,7 +1508,9 @@
|
|
|
1447
1508
|
"type": "column",
|
|
1448
1509
|
"value": "nationalityid"
|
|
1449
1510
|
}
|
|
1450
|
-
]
|
|
1511
|
+
],
|
|
1512
|
+
"pk": true,
|
|
1513
|
+
"unique": false
|
|
1451
1514
|
}
|
|
1452
1515
|
],
|
|
1453
1516
|
"public.order_items": [
|
|
@@ -1463,7 +1526,9 @@
|
|
|
1463
1526
|
"type": "column",
|
|
1464
1527
|
"value": "product_id"
|
|
1465
1528
|
}
|
|
1466
|
-
]
|
|
1529
|
+
],
|
|
1530
|
+
"pk": false,
|
|
1531
|
+
"unique": true
|
|
1467
1532
|
},
|
|
1468
1533
|
{
|
|
1469
1534
|
"name": "idx_order_items_order_product",
|
|
@@ -1477,7 +1542,9 @@
|
|
|
1477
1542
|
"type": "column",
|
|
1478
1543
|
"value": "product_id"
|
|
1479
1544
|
}
|
|
1480
|
-
]
|
|
1545
|
+
],
|
|
1546
|
+
"pk": false,
|
|
1547
|
+
"unique": false
|
|
1481
1548
|
}
|
|
1482
1549
|
],
|
|
1483
1550
|
"public.orders": [
|
|
@@ -1493,7 +1560,9 @@
|
|
|
1493
1560
|
"type": "column",
|
|
1494
1561
|
"value": "order_date"
|
|
1495
1562
|
}
|
|
1496
|
-
]
|
|
1563
|
+
],
|
|
1564
|
+
"pk": false,
|
|
1565
|
+
"unique": false
|
|
1497
1566
|
}
|
|
1498
1567
|
],
|
|
1499
1568
|
"public.products": [
|
|
@@ -1505,7 +1574,43 @@
|
|
|
1505
1574
|
"type": "column",
|
|
1506
1575
|
"value": "category"
|
|
1507
1576
|
}
|
|
1508
|
-
]
|
|
1577
|
+
],
|
|
1578
|
+
"pk": false,
|
|
1579
|
+
"unique": false
|
|
1580
|
+
}
|
|
1581
|
+
],
|
|
1582
|
+
"public.table_with_composite_primary_and_unique_indexes": [
|
|
1583
|
+
{
|
|
1584
|
+
"name": "table_with_composite_primary_and_unique_indexes_pkey",
|
|
1585
|
+
"type": "btree",
|
|
1586
|
+
"columns": [
|
|
1587
|
+
{
|
|
1588
|
+
"type": "column",
|
|
1589
|
+
"value": "col1"
|
|
1590
|
+
},
|
|
1591
|
+
{
|
|
1592
|
+
"type": "column",
|
|
1593
|
+
"value": "col2"
|
|
1594
|
+
}
|
|
1595
|
+
],
|
|
1596
|
+
"pk": true,
|
|
1597
|
+
"unique": false
|
|
1598
|
+
},
|
|
1599
|
+
{
|
|
1600
|
+
"name": "table_with_composite_primary_and_unique_indexes_col3_col4_key",
|
|
1601
|
+
"type": "btree",
|
|
1602
|
+
"columns": [
|
|
1603
|
+
{
|
|
1604
|
+
"type": "column",
|
|
1605
|
+
"value": "col3"
|
|
1606
|
+
},
|
|
1607
|
+
{
|
|
1608
|
+
"type": "column",
|
|
1609
|
+
"value": "col4"
|
|
1610
|
+
}
|
|
1611
|
+
],
|
|
1612
|
+
"pk": false,
|
|
1613
|
+
"unique": true
|
|
1509
1614
|
}
|
|
1510
1615
|
],
|
|
1511
1616
|
"public.users": [
|
|
@@ -1517,7 +1622,9 @@
|
|
|
1517
1622
|
"type": "column",
|
|
1518
1623
|
"value": "full_name"
|
|
1519
1624
|
}
|
|
1520
|
-
]
|
|
1625
|
+
],
|
|
1626
|
+
"pk": false,
|
|
1627
|
+
"unique": false
|
|
1521
1628
|
},
|
|
1522
1629
|
{
|
|
1523
1630
|
"name": "idx_users_email",
|
|
@@ -1527,7 +1634,9 @@
|
|
|
1527
1634
|
"type": "column",
|
|
1528
1635
|
"value": "email"
|
|
1529
1636
|
}
|
|
1530
|
-
]
|
|
1637
|
+
],
|
|
1638
|
+
"pk": false,
|
|
1639
|
+
"unique": false
|
|
1531
1640
|
},
|
|
1532
1641
|
{
|
|
1533
1642
|
"name": "users_is_active_lower_idx",
|
|
@@ -1541,79 +1650,181 @@
|
|
|
1541
1650
|
"type": "expression",
|
|
1542
1651
|
"value": "lower((full_name)::text)"
|
|
1543
1652
|
}
|
|
1544
|
-
]
|
|
1653
|
+
],
|
|
1654
|
+
"pk": false,
|
|
1655
|
+
"unique": false
|
|
1545
1656
|
}
|
|
1546
1657
|
]
|
|
1547
1658
|
},
|
|
1548
1659
|
"tableConstraints": {
|
|
1549
1660
|
"public.all_default_values": {
|
|
1550
1661
|
"id": {
|
|
1662
|
+
"checks": [],
|
|
1551
1663
|
"pk": true
|
|
1552
1664
|
}
|
|
1553
1665
|
},
|
|
1554
1666
|
"public.books": {
|
|
1555
1667
|
"bookid": {
|
|
1668
|
+
"checks": [],
|
|
1556
1669
|
"pk": true
|
|
1557
1670
|
},
|
|
1558
1671
|
"isbn": {
|
|
1672
|
+
"checks": [],
|
|
1559
1673
|
"unique": true
|
|
1560
1674
|
}
|
|
1561
1675
|
},
|
|
1562
1676
|
"public.order_items": {
|
|
1563
1677
|
"order_item_id": {
|
|
1678
|
+
"checks": [],
|
|
1564
1679
|
"pk": true
|
|
1680
|
+
},
|
|
1681
|
+
"quantity": {
|
|
1682
|
+
"checks": [
|
|
1683
|
+
{
|
|
1684
|
+
"name": "chk_quantity_positive",
|
|
1685
|
+
"expression": "quantity > 0"
|
|
1686
|
+
}
|
|
1687
|
+
]
|
|
1688
|
+
},
|
|
1689
|
+
"unit_price": {
|
|
1690
|
+
"checks": [
|
|
1691
|
+
{
|
|
1692
|
+
"name": "chk_unit_price_positive",
|
|
1693
|
+
"expression": "unit_price > (0)::numeric"
|
|
1694
|
+
}
|
|
1695
|
+
]
|
|
1565
1696
|
}
|
|
1566
1697
|
},
|
|
1567
1698
|
"public.orders": {
|
|
1568
1699
|
"order_id": {
|
|
1700
|
+
"checks": [],
|
|
1569
1701
|
"pk": true
|
|
1702
|
+
},
|
|
1703
|
+
"total_amount": {
|
|
1704
|
+
"checks": [
|
|
1705
|
+
{
|
|
1706
|
+
"name": "chk_total_amount_positive",
|
|
1707
|
+
"expression": "total_amount > (0)::numeric"
|
|
1708
|
+
}
|
|
1709
|
+
]
|
|
1710
|
+
},
|
|
1711
|
+
"status": {
|
|
1712
|
+
"checks": [
|
|
1713
|
+
{
|
|
1714
|
+
"name": "chk_status",
|
|
1715
|
+
"expression": "(status)::text = ANY ((ARRAY['pending'::character varying, 'processing'::character varying, 'shipped'::character varying, 'delivered'::character varying, 'cancelled'::character varying])::text[])"
|
|
1716
|
+
}
|
|
1717
|
+
]
|
|
1570
1718
|
}
|
|
1571
1719
|
},
|
|
1572
1720
|
"public.products": {
|
|
1573
1721
|
"product_id": {
|
|
1722
|
+
"checks": [],
|
|
1574
1723
|
"pk": true
|
|
1724
|
+
},
|
|
1725
|
+
"price": {
|
|
1726
|
+
"checks": [
|
|
1727
|
+
{
|
|
1728
|
+
"name": "chk_price_positive",
|
|
1729
|
+
"expression": "price > (0)::numeric"
|
|
1730
|
+
}
|
|
1731
|
+
]
|
|
1732
|
+
},
|
|
1733
|
+
"stock_quantity": {
|
|
1734
|
+
"checks": [
|
|
1735
|
+
{
|
|
1736
|
+
"name": "chk_stock_non_negative",
|
|
1737
|
+
"expression": "stock_quantity >= 0"
|
|
1738
|
+
}
|
|
1739
|
+
]
|
|
1575
1740
|
}
|
|
1576
1741
|
},
|
|
1577
1742
|
"public.table1": {
|
|
1578
1743
|
"id": {
|
|
1744
|
+
"checks": [],
|
|
1579
1745
|
"pk": true
|
|
1580
1746
|
}
|
|
1581
1747
|
},
|
|
1582
1748
|
"dbml_test.table1": {
|
|
1583
1749
|
"id": {
|
|
1750
|
+
"checks": [],
|
|
1584
1751
|
"pk": true
|
|
1585
1752
|
}
|
|
1586
1753
|
},
|
|
1587
1754
|
"public.table2": {
|
|
1588
1755
|
"id": {
|
|
1756
|
+
"checks": [],
|
|
1589
1757
|
"pk": true
|
|
1590
1758
|
}
|
|
1591
1759
|
},
|
|
1592
1760
|
"dbml_test.table3": {
|
|
1593
1761
|
"id": {
|
|
1762
|
+
"checks": [],
|
|
1594
1763
|
"pk": true
|
|
1595
1764
|
}
|
|
1596
1765
|
},
|
|
1597
1766
|
"public.table_with_comments": {
|
|
1598
1767
|
"id": {
|
|
1768
|
+
"checks": [],
|
|
1599
1769
|
"pk": true
|
|
1600
1770
|
}
|
|
1601
1771
|
},
|
|
1602
1772
|
"public.user_define_data_types": {
|
|
1603
1773
|
"id": {
|
|
1774
|
+
"checks": [],
|
|
1604
1775
|
"pk": true
|
|
1776
|
+
},
|
|
1777
|
+
"height": {
|
|
1778
|
+
"checks": [
|
|
1779
|
+
{
|
|
1780
|
+
"name": "user_define_data_types_height_check",
|
|
1781
|
+
"expression": "height > (0)::double precision"
|
|
1782
|
+
}
|
|
1783
|
+
]
|
|
1784
|
+
},
|
|
1785
|
+
"weight": {
|
|
1786
|
+
"checks": [
|
|
1787
|
+
{
|
|
1788
|
+
"name": "chk_positive_weight",
|
|
1789
|
+
"expression": "weight > (0)::double precision"
|
|
1790
|
+
}
|
|
1791
|
+
]
|
|
1605
1792
|
}
|
|
1606
1793
|
},
|
|
1607
1794
|
"public.users": {
|
|
1608
1795
|
"user_id": {
|
|
1796
|
+
"checks": [],
|
|
1609
1797
|
"pk": true
|
|
1610
1798
|
},
|
|
1611
1799
|
"email": {
|
|
1800
|
+
"checks": [
|
|
1801
|
+
{
|
|
1802
|
+
"name": "chk_email_format",
|
|
1803
|
+
"expression": "(email)::text ~* '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}$'::text"
|
|
1804
|
+
}
|
|
1805
|
+
],
|
|
1612
1806
|
"unique": true
|
|
1613
1807
|
},
|
|
1614
1808
|
"username": {
|
|
1809
|
+
"checks": [],
|
|
1615
1810
|
"unique": true
|
|
1811
|
+
},
|
|
1812
|
+
"date_of_birth": {
|
|
1813
|
+
"checks": [
|
|
1814
|
+
{
|
|
1815
|
+
"name": "chk_age",
|
|
1816
|
+
"expression": "date_of_birth <= (CURRENT_DATE - '13 years'::interval)"
|
|
1817
|
+
}
|
|
1818
|
+
]
|
|
1616
1819
|
}
|
|
1617
1820
|
}
|
|
1821
|
+
},
|
|
1822
|
+
"checks": {
|
|
1823
|
+
"public.products": [
|
|
1824
|
+
{
|
|
1825
|
+
"name": "chk_created_at",
|
|
1826
|
+
"expression": "created_at <= updated_at"
|
|
1827
|
+
}
|
|
1828
|
+
]
|
|
1618
1829
|
}
|
|
1619
1830
|
}
|
|
@@ -46,8 +46,7 @@ function getDbDefault(columnDefault, defaultValueType) {
|
|
|
46
46
|
}
|
|
47
47
|
if (defaultValueType === 'string') {
|
|
48
48
|
// bigquery store the double qoutes and quotes at the end and the beginning of the string: "string" or 'string'
|
|
49
|
-
|
|
50
|
-
return { value: columnDefault.slice(1, -1).replaceAll("'", "\'"), type: defaultValueType };
|
|
49
|
+
return { value: columnDefault.slice(1, -1).replaceAll('\'', '\''), type: defaultValueType };
|
|
51
50
|
}
|
|
52
51
|
return { value: columnDefault, type: defaultValueType };
|
|
53
52
|
}
|
|
@@ -209,7 +208,7 @@ async function generateTableConstraints(client, projectId, datasetId) {
|
|
|
209
208
|
inlinePrimaryKeyMap[key] = {};
|
|
210
209
|
}
|
|
211
210
|
if (!inlinePrimaryKeyMap[key][columnNames]) {
|
|
212
|
-
inlinePrimaryKeyMap[key][columnNames] = {};
|
|
211
|
+
inlinePrimaryKeyMap[key][columnNames] = { checks: [] };
|
|
213
212
|
}
|
|
214
213
|
inlinePrimaryKeyMap[key][columnNames].pk = true;
|
|
215
214
|
});
|
|
@@ -266,6 +265,8 @@ async function fetchSchemaJsonByDataset(client, projectId, datasetId) {
|
|
|
266
265
|
enums: [],
|
|
267
266
|
indexes: (0, helpers_1.mergeIndexDictionary)(indexMap, compositePrimaryKeyMap),
|
|
268
267
|
tableConstraints: inlinePrimaryKeyMap,
|
|
268
|
+
// Checks are not supported in BigQuery
|
|
269
|
+
checks: {},
|
|
269
270
|
};
|
|
270
271
|
}
|
|
271
272
|
async function fetchSchemaJson(keyFilename) {
|
|
@@ -284,7 +285,7 @@ async function fetchSchemaJson(keyFilename) {
|
|
|
284
285
|
acc.tableConstraints = (0, helpers_1.mergeTableConstraintDictionary)(acc.tableConstraints, tableConstraints);
|
|
285
286
|
return acc;
|
|
286
287
|
}, {
|
|
287
|
-
tables: [], fields: {}, tableConstraints: {}, indexes: {}, refs: [], enums: [],
|
|
288
|
+
tables: [], fields: {}, tableConstraints: {}, indexes: {}, refs: [], enums: [], checks: {},
|
|
288
289
|
});
|
|
289
290
|
return res;
|
|
290
291
|
}
|