@dbml/connector 5.3.1 → 5.4.1

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.
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import { scanDirNames } from '../jestHelpers.ts';
4
- import { connector } from '../src/index.ts';
3
+ import { scanDirNames } from './testHelpers';
4
+ import { connector } from '../src/index';
5
5
 
6
6
  const sortKeys = (obj: any): any => {
7
7
  if (Array.isArray(obj)) {
@@ -84,6 +84,13 @@
84
84
  "value": "This table stores information about various items."
85
85
  }
86
86
  },
87
+ {
88
+ "name": "table_with_composite_primary_and_unique_indexes",
89
+ "schemaName": "dbo",
90
+ "note": {
91
+ "value": ""
92
+ }
93
+ },
87
94
  {
88
95
  "name": "Authors",
89
96
  "schemaName": "dbo",
@@ -97,6 +104,27 @@
97
104
  "note": {
98
105
  "value": ""
99
106
  }
107
+ },
108
+ {
109
+ "name": "AddressInfo",
110
+ "schemaName": "dbo",
111
+ "note": {
112
+ "value": ""
113
+ }
114
+ },
115
+ {
116
+ "name": "AddressInfo2",
117
+ "schemaName": "dbo",
118
+ "note": {
119
+ "value": ""
120
+ }
121
+ },
122
+ {
123
+ "name": "TestDescriptionTable",
124
+ "schemaName": "dbo",
125
+ "note": {
126
+ "value": "This is the custom comment name on table."
127
+ }
100
128
  }
101
129
  ],
102
130
  "fields": {
@@ -454,8 +482,8 @@
454
482
  {
455
483
  "name": "status",
456
484
  "type": {
457
- "type_name": "chk_status",
458
- "schemaName": "dbo"
485
+ "type_name": "varchar(20)",
486
+ "schemaName": null
459
487
  },
460
488
  "dbdefault": {
461
489
  "type": "string",
@@ -1141,7 +1169,7 @@
1141
1169
  },
1142
1170
  "dbdefault": {
1143
1171
  "type": "string",
1144
- "value": "<Books>\r\n <Book>\r\n <Title>The Great Gatsby</Title>\r\n <Author>F. Scott Fitzgerald</Author>\r\n <Year>1925</Year>\r\n <Price>10.99</Price>\r\n <Publisher>Scribner</Publisher>\r\n <Location>New York</Location>\r\n <Genre>Fiction</Genre>\r\n <Subgenre>Classic</Subgenre>\r\n </Book>\r\n <Book>\r\n <Title>1984</Title>\r\n <Author>George Orwell</Author>\r\n <Year>1949</Year>\r\n <Price>8.99</Price>\r\n <Publisher>Secker & Warburg</Publisher>\r\n <Location>London</Location>\r\n <Genre>Dystopian</Genre>\r\n <Subgenre>Political Fiction</Subgenre>\r\n </Book>\r\n </Books>"
1172
+ "value": "<Books>\n <Book>\n <Title>The Great Gatsby</Title>\n <Author>F. Scott Fitzgerald</Author>\n <Year>1925</Year>\n <Price>10.99</Price>\n <Publisher>Scribner</Publisher>\n <Location>New York</Location>\n <Genre>Fiction</Genre>\n <Subgenre>Classic</Subgenre>\n </Book>\n <Book>\n <Title>1984</Title>\n <Author>George Orwell</Author>\n <Year>1949</Year>\n <Price>8.99</Price>\n <Publisher>Secker & Warburg</Publisher>\n <Location>London</Location>\n <Genre>Dystopian</Genre>\n <Subgenre>Political Fiction</Subgenre>\n </Book>\n </Books>"
1145
1173
  },
1146
1174
  "not_null": false,
1147
1175
  "increment": false,
@@ -1275,8 +1303,8 @@
1275
1303
  {
1276
1304
  "name": "gender",
1277
1305
  "type": {
1278
- "type_name": "chk_gender",
1279
- "schemaName": "dbo"
1306
+ "type_name": "nvarchar(10)",
1307
+ "schemaName": null
1280
1308
  },
1281
1309
  "dbdefault": null,
1282
1310
  "not_null": false,
@@ -1395,6 +1423,60 @@
1395
1423
  }
1396
1424
  }
1397
1425
  ],
1426
+ "dbo.table_with_composite_primary_and_unique_indexes": [
1427
+ {
1428
+ "name": "col1",
1429
+ "type": {
1430
+ "type_name": "int(10)",
1431
+ "schemaName": null
1432
+ },
1433
+ "dbdefault": null,
1434
+ "not_null": true,
1435
+ "increment": false,
1436
+ "note": {
1437
+ "value": ""
1438
+ }
1439
+ },
1440
+ {
1441
+ "name": "col2",
1442
+ "type": {
1443
+ "type_name": "int(10)",
1444
+ "schemaName": null
1445
+ },
1446
+ "dbdefault": null,
1447
+ "not_null": true,
1448
+ "increment": false,
1449
+ "note": {
1450
+ "value": ""
1451
+ }
1452
+ },
1453
+ {
1454
+ "name": "col3",
1455
+ "type": {
1456
+ "type_name": "int(10)",
1457
+ "schemaName": null
1458
+ },
1459
+ "dbdefault": null,
1460
+ "not_null": false,
1461
+ "increment": false,
1462
+ "note": {
1463
+ "value": ""
1464
+ }
1465
+ },
1466
+ {
1467
+ "name": "col4",
1468
+ "type": {
1469
+ "type_name": "int(10)",
1470
+ "schemaName": null
1471
+ },
1472
+ "dbdefault": null,
1473
+ "not_null": false,
1474
+ "increment": false,
1475
+ "note": {
1476
+ "value": ""
1477
+ }
1478
+ }
1479
+ ],
1398
1480
  "dbo.Authors": [
1399
1481
  {
1400
1482
  "name": "AuthorID",
@@ -1515,46 +1597,119 @@
1515
1597
  "value": ""
1516
1598
  }
1517
1599
  }
1518
- ]
1519
- },
1520
- "enums": [
1521
- {
1522
- "name": "chk_status",
1523
- "schemaName": "dbo",
1524
- "values": [
1525
- {
1526
- "name": "cancelled"
1600
+ ],
1601
+ "dbo.AddressInfo": [
1602
+ {
1603
+ "name": "AddressID",
1604
+ "type": {
1605
+ "type_name": "uniqueidentifier(16)",
1606
+ "schemaName": null
1527
1607
  },
1528
- {
1529
- "name": "delivered"
1608
+ "dbdefault": null,
1609
+ "not_null": true,
1610
+ "increment": false,
1611
+ "note": {
1612
+ "value": ""
1613
+ }
1614
+ },
1615
+ {
1616
+ "name": "AddressFormatID",
1617
+ "type": {
1618
+ "type_name": "uniqueidentifier(16)",
1619
+ "schemaName": null
1530
1620
  },
1531
- {
1532
- "name": "shipped"
1621
+ "dbdefault": null,
1622
+ "not_null": true,
1623
+ "increment": false,
1624
+ "note": {
1625
+ "value": ""
1626
+ }
1627
+ }
1628
+ ],
1629
+ "dbo.AddressInfo2": [
1630
+ {
1631
+ "name": "A1",
1632
+ "type": {
1633
+ "type_name": "uniqueidentifier(16)",
1634
+ "schemaName": null
1533
1635
  },
1534
- {
1535
- "name": "processing"
1636
+ "dbdefault": null,
1637
+ "not_null": true,
1638
+ "increment": false,
1639
+ "note": {
1640
+ "value": ""
1641
+ }
1642
+ },
1643
+ {
1644
+ "name": "A2",
1645
+ "type": {
1646
+ "type_name": "uniqueidentifier(16)",
1647
+ "schemaName": null
1536
1648
  },
1537
- {
1538
- "name": "pending"
1649
+ "dbdefault": null,
1650
+ "not_null": true,
1651
+ "increment": false,
1652
+ "note": {
1653
+ "value": ""
1539
1654
  }
1540
- ]
1541
- },
1542
- {
1543
- "name": "chk_gender",
1544
- "schemaName": "dbo",
1545
- "values": [
1546
- {
1547
- "name": "Other"
1655
+ },
1656
+ {
1657
+ "name": "A3",
1658
+ "type": {
1659
+ "type_name": "uniqueidentifier(16)",
1660
+ "schemaName": null
1548
1661
  },
1549
- {
1550
- "name": "Female"
1662
+ "dbdefault": null,
1663
+ "not_null": true,
1664
+ "increment": false,
1665
+ "note": {
1666
+ "value": ""
1667
+ }
1668
+ },
1669
+ {
1670
+ "name": "A4",
1671
+ "type": {
1672
+ "type_name": "uniqueidentifier(16)",
1673
+ "schemaName": null
1551
1674
  },
1552
- {
1553
- "name": "Male"
1675
+ "dbdefault": null,
1676
+ "not_null": true,
1677
+ "increment": false,
1678
+ "note": {
1679
+ "value": ""
1554
1680
  }
1555
- ]
1556
- }
1557
- ],
1681
+ }
1682
+ ],
1683
+ "dbo.TestDescriptionTable": [
1684
+ {
1685
+ "name": "Id",
1686
+ "type": {
1687
+ "type_name": "int(10)",
1688
+ "schemaName": null
1689
+ },
1690
+ "dbdefault": null,
1691
+ "not_null": false,
1692
+ "increment": false,
1693
+ "note": {
1694
+ "value": "Primary key identifier."
1695
+ }
1696
+ },
1697
+ {
1698
+ "name": "Name",
1699
+ "type": {
1700
+ "type_name": "nvarchar(100)",
1701
+ "schemaName": null
1702
+ },
1703
+ "dbdefault": null,
1704
+ "not_null": false,
1705
+ "increment": false,
1706
+ "note": {
1707
+ "value": "Name of the entity."
1708
+ }
1709
+ }
1710
+ ]
1711
+ },
1712
+ "enums": [],
1558
1713
  "refs": [
1559
1714
  {
1560
1715
  "name": "FK_AuthorNationality",
@@ -1688,7 +1843,9 @@
1688
1843
  "type": "column",
1689
1844
  "value": "product_id"
1690
1845
  }
1691
- ]
1846
+ ],
1847
+ "pk": false,
1848
+ "unique": false
1692
1849
  }
1693
1850
  ],
1694
1851
  "dbo.orders": [
@@ -1704,7 +1861,9 @@
1704
1861
  "type": "column",
1705
1862
  "value": "order_date"
1706
1863
  }
1707
- ]
1864
+ ],
1865
+ "pk": false,
1866
+ "unique": false
1708
1867
  }
1709
1868
  ],
1710
1869
  "dbo.products": [
@@ -1716,7 +1875,9 @@
1716
1875
  "type": "column",
1717
1876
  "value": "category"
1718
1877
  }
1719
- ]
1878
+ ],
1879
+ "pk": false,
1880
+ "unique": false
1720
1881
  }
1721
1882
  ],
1722
1883
  "dbo.users": [
@@ -1728,7 +1889,9 @@
1728
1889
  "type": "column",
1729
1890
  "value": "email"
1730
1891
  }
1731
- ]
1892
+ ],
1893
+ "pk": false,
1894
+ "unique": false
1732
1895
  },
1733
1896
  {
1734
1897
  "name": "idx_users_full_name",
@@ -1738,7 +1901,9 @@
1738
1901
  "type": "column",
1739
1902
  "value": "full_name"
1740
1903
  }
1741
- ]
1904
+ ],
1905
+ "pk": false,
1906
+ "unique": false
1742
1907
  },
1743
1908
  {
1744
1909
  "name": "idx_users_is_active_full_name",
@@ -1752,107 +1917,249 @@
1752
1917
  "type": "column",
1753
1918
  "value": "full_name_lower"
1754
1919
  }
1755
- ]
1920
+ ],
1921
+ "pk": false,
1922
+ "unique": false
1756
1923
  }
1757
1924
  ]
1758
1925
  },
1759
1926
  "tableConstraints": {
1760
1927
  "dbo.Authors": {
1761
1928
  "AuthorID": {
1929
+ "checks": [],
1762
1930
  "pk": true
1763
1931
  },
1764
1932
  "NationalityID": {
1933
+ "checks": [],
1765
1934
  "pk": true
1766
1935
  },
1767
1936
  "AuthorName": {
1937
+ "checks": [],
1768
1938
  "unique": true
1769
1939
  },
1770
1940
  "BirthYear": {
1941
+ "checks": [],
1771
1942
  "unique": true
1772
1943
  }
1773
1944
  },
1774
1945
  "dbo.Books": {
1775
1946
  "BookID": {
1947
+ "checks": [],
1776
1948
  "pk": true
1777
1949
  },
1778
1950
  "AuthorID": {
1951
+ "checks": [],
1779
1952
  "pk": true
1780
1953
  },
1781
1954
  "ISBN": {
1955
+ "checks": [],
1782
1956
  "unique": true
1783
1957
  }
1784
1958
  },
1785
1959
  "dbo.DatetimeTypes": {
1786
1960
  "ID": {
1961
+ "checks": [],
1787
1962
  "pk": true
1788
1963
  }
1789
1964
  },
1790
1965
  "dbo.gender_reference": {
1791
1966
  "value": {
1967
+ "checks": [],
1792
1968
  "pk": true
1793
1969
  }
1794
1970
  },
1795
1971
  "dbo.NumberTypes": {
1796
1972
  "ID": {
1973
+ "checks": [],
1797
1974
  "pk": true
1798
1975
  }
1799
1976
  },
1800
1977
  "dbo.NumberTypesNoDefault": {
1801
1978
  "ID": {
1979
+ "checks": [],
1802
1980
  "pk": true
1803
1981
  }
1804
1982
  },
1805
1983
  "dbo.ObjectTypes": {
1806
1984
  "Id": {
1985
+ "checks": [],
1807
1986
  "pk": true
1808
1987
  }
1809
1988
  },
1810
1989
  "dbo.order_items": {
1811
1990
  "order_item_id": {
1991
+ "checks": [],
1812
1992
  "pk": true
1813
1993
  },
1814
1994
  "order_id": {
1995
+ "checks": [],
1815
1996
  "unique": true
1816
1997
  },
1817
1998
  "product_id": {
1999
+ "checks": [],
1818
2000
  "unique": true
2001
+ },
2002
+ "quantity": {
2003
+ "checks": [
2004
+ {
2005
+ "name": "chk_quantity_positive",
2006
+ "expression": "[quantity]>(0)"
2007
+ }
2008
+ ]
2009
+ },
2010
+ "unit_price": {
2011
+ "checks": [
2012
+ {
2013
+ "name": "chk_unit_price_positive",
2014
+ "expression": "[unit_price]>(0)"
2015
+ }
2016
+ ]
1819
2017
  }
1820
2018
  },
1821
2019
  "dbo.orders": {
1822
2020
  "order_id": {
2021
+ "checks": [],
1823
2022
  "pk": true
2023
+ },
2024
+ "total_amount": {
2025
+ "checks": [
2026
+ {
2027
+ "name": "chk_total_amount_positive",
2028
+ "expression": "[total_amount]>(0)"
2029
+ }
2030
+ ]
2031
+ },
2032
+ "status": {
2033
+ "checks": [
2034
+ {
2035
+ "name": "chk_status",
2036
+ "expression": "[status]='cancelled' OR [status]='delivered' OR [status]='shipped' OR [status]='processing' OR [status]='pending'"
2037
+ }
2038
+ ]
1824
2039
  }
1825
2040
  },
1826
2041
  "dbo.products": {
1827
2042
  "product_id": {
2043
+ "checks": [],
1828
2044
  "pk": true
2045
+ },
2046
+ "price": {
2047
+ "checks": [
2048
+ {
2049
+ "name": "chk_price_positive",
2050
+ "expression": "[price]>(0)"
2051
+ }
2052
+ ]
2053
+ },
2054
+ "stock_quantity": {
2055
+ "checks": [
2056
+ {
2057
+ "name": "chk_stock_non_negative",
2058
+ "expression": "[stock_quantity]>=(0)"
2059
+ }
2060
+ ]
1829
2061
  }
1830
2062
  },
1831
2063
  "dbo.StringTypes": {
1832
2064
  "Id": {
2065
+ "checks": [],
1833
2066
  "pk": true
1834
2067
  }
1835
2068
  },
1836
2069
  "dbo.table_with_comments": {
1837
2070
  "id": {
2071
+ "checks": [],
2072
+ "pk": true
2073
+ }
2074
+ },
2075
+ "dbo.table_with_composite_primary_and_unique_indexes": {
2076
+ "col1": {
2077
+ "checks": [],
2078
+ "pk": true
2079
+ },
2080
+ "col2": {
2081
+ "checks": [],
1838
2082
  "pk": true
2083
+ },
2084
+ "col3": {
2085
+ "checks": [],
2086
+ "unique": true
2087
+ },
2088
+ "col4": {
2089
+ "checks": [],
2090
+ "unique": true
1839
2091
  }
1840
2092
  },
1841
2093
  "dbo.user_define_data_types": {
1842
2094
  "id": {
2095
+ "checks": [],
1843
2096
  "pk": true
2097
+ },
2098
+ "gender": {
2099
+ "checks": [
2100
+ {
2101
+ "name": "chk_gender",
2102
+ "expression": "[gender]='Other' OR [gender]='Female' OR [gender]='Male'"
2103
+ }
2104
+ ]
1844
2105
  }
1845
2106
  },
1846
2107
  "dbo.users": {
1847
2108
  "user_id": {
2109
+ "checks": [],
1848
2110
  "pk": true
1849
2111
  },
1850
2112
  "email": {
2113
+ "checks": [
2114
+ {
2115
+ "name": "chk_email_format",
2116
+ "expression": "[email] like '%_@_%._%'"
2117
+ }
2118
+ ],
1851
2119
  "unique": true
1852
2120
  },
1853
2121
  "username": {
2122
+ "checks": [],
1854
2123
  "unique": true
2124
+ },
2125
+ "date_of_birth": {
2126
+ "checks": [
2127
+ {
2128
+ "name": "chk_age",
2129
+ "expression": "[date_of_birth]<=dateadd(year,(-13),getdate())"
2130
+ }
2131
+ ]
2132
+ }
2133
+ },
2134
+ "dbo.TestDescriptionTable": {
2135
+ "Name": {
2136
+ "checks": [
2137
+ {
2138
+ "name": "chk_name_len",
2139
+ "expression": "len([Name])>(6)"
2140
+ }
2141
+ ]
1855
2142
  }
1856
2143
  }
2144
+ },
2145
+ "checks": {
2146
+ "dbo.user_define_data_types": [
2147
+ {
2148
+ "name": "chk_age_range",
2149
+ "expression": "[age_start]<=[age_end]"
2150
+ }
2151
+ ],
2152
+ "dbo.AddressInfo": [
2153
+ {
2154
+ "name": "CK_Address_Valid",
2155
+ "expression": "([AddressID]='176029FA-D6D3-49E1-A48C-000000000002' OR [AddressID]='176029FA-D6D3-49E1-A48C-000000000001') AND ([AddressFormatID]='176029FA-D6D3-49E1-A48C-000000000002' OR [AddressFormatID]='176029FA-D6D3-49E1-A48C-000000000001')"
2156
+ }
2157
+ ],
2158
+ "dbo.AddressInfo2": [
2159
+ {
2160
+ "name": "CK_Address_Valid2",
2161
+ "expression": "([A1]='333' OR [A1]='2222' OR [A1]='1111') AND ([A2]='2222' OR [A2]='1111') AND ([A3]='1111' OR [A3]='2222') AND ([A4]='3333' OR [A4]='2222')"
2162
+ }
2163
+ ]
1857
2164
  }
1858
2165
  }