Skip to content

Commit 50cf427

Browse files
author
Gil Mizrahi
authored
Support network_supeq and network_subeq by default (#541)
### What This PR lists network_supeq and network_subeq in the default allowed prefix functions, to complete support for types such as CIDR. ### How Add them to the default list, add tests, and regenerate configs.
1 parent 60c5d20 commit 50cf427

17 files changed

+5172
-2
lines changed

crates/configuration/src/version5/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ fn default_introspect_prefix_function_comparison_operators() -> Vec<String> {
155155
"lseg_perp".to_string(),
156156
"network_overlap".to_string(),
157157
"network_sub".to_string(),
158+
"network_subeq".to_string(),
158159
"network_sup".to_string(),
160+
"network_supeq".to_string(),
159161
"on_pb".to_string(),
160162
"on_pl".to_string(),
161163
"on_ppath".to_string(),

crates/tests/databases-tests/src/postgres/query_tests.rs

+6
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ mod predicates {
255255
insta::assert_json_snapshot!(result);
256256
}
257257

258+
#[tokio::test]
259+
async fn where_cidr_network_supeq() {
260+
let result = run_query(create_router().await, "where_cidr_network_supeq").await;
261+
insta::assert_json_snapshot!(result);
262+
}
263+
258264
#[tokio::test]
259265
async fn select_where_or() {
260266
let result = run_query(create_router().await, "select_where_or").await;

crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__cli_version3_tests__postgres_current_only_configure_initial_configuration_is_unchanged.snap

+101
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,31 @@ expression: default_configuration
883883
"foreignRelations": {},
884884
"description": null
885885
},
886+
"custom_test_cidr": {
887+
"schemaName": "custom",
888+
"tableName": "test_cidr",
889+
"columns": {
890+
"ip": {
891+
"name": "ip",
892+
"type": {
893+
"scalarType": "cidr"
894+
},
895+
"nullable": "nullable",
896+
"description": null
897+
},
898+
"service": {
899+
"name": "service",
900+
"type": {
901+
"scalarType": "text"
902+
},
903+
"nullable": "nullable",
904+
"description": null
905+
}
906+
},
907+
"uniquenessConstraints": {},
908+
"foreignRelations": {},
909+
"description": null
910+
},
886911
"deck_of_cards": {
887912
"schemaName": "public",
888913
"tableName": "deck_of_cards",
@@ -1282,6 +1307,14 @@ expression: default_configuration
12821307
"returnType": "card_suit"
12831308
}
12841309
},
1310+
"cidr": {
1311+
"max": {
1312+
"returnType": "inet"
1313+
},
1314+
"min": {
1315+
"returnType": "inet"
1316+
}
1317+
},
12851318
"date": {
12861319
"max": {
12871320
"returnType": "date"
@@ -1760,6 +1793,74 @@ expression: default_configuration
17601793
"isInfix": true
17611794
}
17621795
},
1796+
"cidr": {
1797+
"_eq": {
1798+
"operatorName": "=",
1799+
"operatorKind": "equal",
1800+
"argumentType": "cidr",
1801+
"isInfix": true
1802+
},
1803+
"_gt": {
1804+
"operatorName": ">",
1805+
"operatorKind": "custom",
1806+
"argumentType": "cidr",
1807+
"isInfix": true
1808+
},
1809+
"_gte": {
1810+
"operatorName": ">=",
1811+
"operatorKind": "custom",
1812+
"argumentType": "cidr",
1813+
"isInfix": true
1814+
},
1815+
"_in": {
1816+
"operatorName": "IN",
1817+
"operatorKind": "in",
1818+
"argumentType": "cidr",
1819+
"isInfix": true
1820+
},
1821+
"_lt": {
1822+
"operatorName": "<",
1823+
"operatorKind": "custom",
1824+
"argumentType": "cidr",
1825+
"isInfix": true
1826+
},
1827+
"_lte": {
1828+
"operatorName": "<=",
1829+
"operatorKind": "custom",
1830+
"argumentType": "cidr",
1831+
"isInfix": true
1832+
},
1833+
"_neq": {
1834+
"operatorName": "<>",
1835+
"operatorKind": "custom",
1836+
"argumentType": "cidr",
1837+
"isInfix": true
1838+
},
1839+
"inet_same_family": {
1840+
"operatorName": "inet_same_family",
1841+
"operatorKind": "custom",
1842+
"argumentType": "cidr",
1843+
"isInfix": false
1844+
},
1845+
"network_overlap": {
1846+
"operatorName": "network_overlap",
1847+
"operatorKind": "custom",
1848+
"argumentType": "cidr",
1849+
"isInfix": false
1850+
},
1851+
"network_sub": {
1852+
"operatorName": "network_sub",
1853+
"operatorKind": "custom",
1854+
"argumentType": "cidr",
1855+
"isInfix": false
1856+
},
1857+
"network_sup": {
1858+
"operatorName": "network_sup",
1859+
"operatorKind": "custom",
1860+
"argumentType": "cidr",
1861+
"isInfix": false
1862+
}
1863+
},
17631864
"date": {
17641865
"_eq": {
17651866
"operatorName": "=",

crates/tests/databases-tests/src/postgres/snapshots/databases_tests__postgres__cli_version4_tests__postgres_current_only_configure_initial_configuration_is_unchanged.snap

+189
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,31 @@ expression: default_configuration
883883
"foreignRelations": {},
884884
"description": null
885885
},
886+
"custom_test_cidr": {
887+
"schemaName": "custom",
888+
"tableName": "test_cidr",
889+
"columns": {
890+
"ip": {
891+
"name": "ip",
892+
"type": {
893+
"scalarType": "cidr"
894+
},
895+
"nullable": "nullable",
896+
"description": null
897+
},
898+
"service": {
899+
"name": "service",
900+
"type": {
901+
"scalarType": "text"
902+
},
903+
"nullable": "nullable",
904+
"description": null
905+
}
906+
},
907+
"uniquenessConstraints": {},
908+
"foreignRelations": {},
909+
"description": null
910+
},
886911
"deck_of_cards": {
887912
"schemaName": "public",
888913
"tableName": "deck_of_cards",
@@ -1465,6 +1490,88 @@ expression: default_configuration
14651490
]
14661491
}
14671492
},
1493+
"cidr": {
1494+
"typeName": "cidr",
1495+
"schemaName": "pg_catalog",
1496+
"description": null,
1497+
"aggregateFunctions": {
1498+
"max": {
1499+
"returnType": "inet"
1500+
},
1501+
"min": {
1502+
"returnType": "inet"
1503+
}
1504+
},
1505+
"comparisonOperators": {
1506+
"_eq": {
1507+
"operatorName": "=",
1508+
"operatorKind": "equal",
1509+
"argumentType": "cidr",
1510+
"isInfix": true
1511+
},
1512+
"_gt": {
1513+
"operatorName": ">",
1514+
"operatorKind": "custom",
1515+
"argumentType": "cidr",
1516+
"isInfix": true
1517+
},
1518+
"_gte": {
1519+
"operatorName": ">=",
1520+
"operatorKind": "custom",
1521+
"argumentType": "cidr",
1522+
"isInfix": true
1523+
},
1524+
"_in": {
1525+
"operatorName": "IN",
1526+
"operatorKind": "in",
1527+
"argumentType": "cidr",
1528+
"isInfix": true
1529+
},
1530+
"_lt": {
1531+
"operatorName": "<",
1532+
"operatorKind": "custom",
1533+
"argumentType": "cidr",
1534+
"isInfix": true
1535+
},
1536+
"_lte": {
1537+
"operatorName": "<=",
1538+
"operatorKind": "custom",
1539+
"argumentType": "cidr",
1540+
"isInfix": true
1541+
},
1542+
"_neq": {
1543+
"operatorName": "<>",
1544+
"operatorKind": "custom",
1545+
"argumentType": "cidr",
1546+
"isInfix": true
1547+
},
1548+
"inet_same_family": {
1549+
"operatorName": "inet_same_family",
1550+
"operatorKind": "custom",
1551+
"argumentType": "cidr",
1552+
"isInfix": false
1553+
},
1554+
"network_overlap": {
1555+
"operatorName": "network_overlap",
1556+
"operatorKind": "custom",
1557+
"argumentType": "cidr",
1558+
"isInfix": false
1559+
},
1560+
"network_sub": {
1561+
"operatorName": "network_sub",
1562+
"operatorKind": "custom",
1563+
"argumentType": "cidr",
1564+
"isInfix": false
1565+
},
1566+
"network_sup": {
1567+
"operatorName": "network_sup",
1568+
"operatorKind": "custom",
1569+
"argumentType": "cidr",
1570+
"isInfix": false
1571+
}
1572+
},
1573+
"typeRepresentation": null
1574+
},
14681575
"date": {
14691576
"typeName": "date",
14701577
"schemaName": "pg_catalog",
@@ -1696,6 +1803,88 @@ expression: default_configuration
16961803
},
16971804
"typeRepresentation": "float64"
16981805
},
1806+
"inet": {
1807+
"typeName": "inet",
1808+
"schemaName": "pg_catalog",
1809+
"description": null,
1810+
"aggregateFunctions": {
1811+
"max": {
1812+
"returnType": "inet"
1813+
},
1814+
"min": {
1815+
"returnType": "inet"
1816+
}
1817+
},
1818+
"comparisonOperators": {
1819+
"_eq": {
1820+
"operatorName": "=",
1821+
"operatorKind": "equal",
1822+
"argumentType": "inet",
1823+
"isInfix": true
1824+
},
1825+
"_gt": {
1826+
"operatorName": ">",
1827+
"operatorKind": "custom",
1828+
"argumentType": "inet",
1829+
"isInfix": true
1830+
},
1831+
"_gte": {
1832+
"operatorName": ">=",
1833+
"operatorKind": "custom",
1834+
"argumentType": "inet",
1835+
"isInfix": true
1836+
},
1837+
"_in": {
1838+
"operatorName": "IN",
1839+
"operatorKind": "in",
1840+
"argumentType": "inet",
1841+
"isInfix": true
1842+
},
1843+
"_lt": {
1844+
"operatorName": "<",
1845+
"operatorKind": "custom",
1846+
"argumentType": "inet",
1847+
"isInfix": true
1848+
},
1849+
"_lte": {
1850+
"operatorName": "<=",
1851+
"operatorKind": "custom",
1852+
"argumentType": "inet",
1853+
"isInfix": true
1854+
},
1855+
"_neq": {
1856+
"operatorName": "<>",
1857+
"operatorKind": "custom",
1858+
"argumentType": "inet",
1859+
"isInfix": true
1860+
},
1861+
"inet_same_family": {
1862+
"operatorName": "inet_same_family",
1863+
"operatorKind": "custom",
1864+
"argumentType": "inet",
1865+
"isInfix": false
1866+
},
1867+
"network_overlap": {
1868+
"operatorName": "network_overlap",
1869+
"operatorKind": "custom",
1870+
"argumentType": "inet",
1871+
"isInfix": false
1872+
},
1873+
"network_sub": {
1874+
"operatorName": "network_sub",
1875+
"operatorKind": "custom",
1876+
"argumentType": "inet",
1877+
"isInfix": false
1878+
},
1879+
"network_sup": {
1880+
"operatorName": "network_sup",
1881+
"operatorKind": "custom",
1882+
"argumentType": "inet",
1883+
"isInfix": false
1884+
}
1885+
},
1886+
"typeRepresentation": null
1887+
},
16991888
"int2": {
17001889
"typeName": "int2",
17011890
"schemaName": "pg_catalog",

0 commit comments

Comments
 (0)