Skip to content

Commit 67d3c70

Browse files
committed
feat: support network address type in pg
1 parent 8db361b commit 67d3c70

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

pegjs/postgresql.pegjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ alter_sequence_stmt
17711771
}
17721772
}
17731773
}
1774-
1774+
17751775
alter_function_stmt
17761776
= KW_ALTER __ t:'FUNCTION'i __ s:table_name __ ags:(LPAREN __ alter_func_args? __ RPAREN)? __ ac:(ALTER_RENAME / ALTER_OWNER_TO / ALTER_SET_SCHEMA) {
17771777
// => AstStatement<alter_resource_stmt_node>
@@ -5083,7 +5083,7 @@ position_func_clause
50835083
...getLocationObject(),
50845084
};
50855085
}
5086-
5086+
50875087
trim_position
50885088
= 'BOTH'i / 'LEADING'i / 'TRAILING'i
50895089

@@ -5756,6 +5756,10 @@ KW_REGPROC = "REGPROC"i !ident_start { return 'REGPROC'; }
57565756
KW_REGPROCEDURE = "REGPROCEDURE"i !ident_start { return 'REGPROCEDURE'; }
57575757
KW_REGROLE = "REGROLE"i !ident_start { return 'REGROLE'; }
57585758
KW_REGTYPE = "REGTYPE"i !ident_start { return 'REGTYPE'; }
5759+
KW_CIDR = "CIDR"i !ident_start { return 'CIDR'; }
5760+
KW_INET = "INET"i !ident_start { return 'INET'; }
5761+
KW_MACADDR = "MACADDR"i !ident_start { return 'MACADDR'; }
5762+
KW_MACADDR8 = "MACADDR8"i !ident_start { return 'MACADDR8'; }
57595763

57605764
KW_CURRENT_DATE = "CURRENT_DATE"i !ident_start { return 'CURRENT_DATE'; }
57615765
KW_ADD_DATE = "ADDDATE"i !ident_start { return 'ADDDATE'; }
@@ -6121,6 +6125,7 @@ data_type
61216125
/ binary_type
61226126
/ oid_type
61236127
/ record_type
6128+
/ network_address_type
61246129
/ custom_types
61256130

61266131

@@ -6246,6 +6251,9 @@ uuid_type
62466251
record_type
62476252
= 'RECORD'i {/* => data_type */ return { dataType: 'RECORD' }}
62486253

6254+
network_address_type
6255+
= t:(KW_INET / KW_CIDR / KW_MACADDR8 / KW_MACADDR) {/* => data_type */ return { dataType: t }}
6256+
62496257
custom_types
62506258
= name:ident_name &{ return customTypes.has(name) } {
62516259
// => data_type

test/postgres.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,6 +2259,19 @@ describe('Postgres', () => {
22592259
'CREATE UNLOGGED TABLE "t1" (id INTEGER PRIMARY KEY, data TEXT)'
22602260
]
22612261
},
2262+
{
2263+
title: 'network address type',
2264+
sql: [
2265+
`CREATE TABLE "network_address" (
2266+
id integer PRIMARY KEY,
2267+
inet_address inet,
2268+
cidr_address cidr,
2269+
mac_address macaddr,
2270+
mac_address8 macaddr8
2271+
);`,
2272+
'CREATE TABLE "network_address" (id INTEGER PRIMARY KEY, inet_address INET, cidr_address CIDR, mac_address MACADDR, mac_address8 MACADDR8)'
2273+
]
2274+
},
22622275
]
22632276
neatlyNestTestedSQL(SQL_LIST)
22642277
})

0 commit comments

Comments
 (0)