Skip to content

Commit 4daa83b

Browse files
Merge pull request #2590 from taozhi8833998/feat-money-type-pg
feat: add money data type in pg
2 parents 4dbe79b + 8959ade commit 4daa83b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pegjs/postgresql.pegjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5782,6 +5782,7 @@ KW_INET = "INET"i !ident_start { return 'INET'; }
57825782
KW_MACADDR = "MACADDR"i !ident_start { return 'MACADDR'; }
57835783
KW_MACADDR8 = "MACADDR8"i !ident_start { return 'MACADDR8'; }
57845784
KW_BIT = "BIT"i !ident_start { return 'BIT'; }
5785+
KW_MONEY = "MONEY"i !ident_start { return 'MONEY'; }
57855786

57865787
KW_CURRENT_DATE = "CURRENT_DATE"i !ident_start { return 'CURRENT_DATE'; }
57875788
KW_ADD_DATE = "ADDDATE"i !ident_start { return 'ADDDATE'; }
@@ -6149,6 +6150,7 @@ data_type
61496150
/ record_type
61506151
/ network_address_type
61516152
/ bit_type
6153+
/ money_type
61526154
/ custom_types
61536155

61546156

@@ -6202,6 +6204,9 @@ numeric_type
62026204
/ t:(KW_NUMERIC / KW_DECIMAL / KW_INT / KW_INTEGER / KW_SMALLINT / KW_TINYINT / KW_MEDIUMINT / KW_BIGINT / KW_FLOAT / KW_DOUBLE __ 'PRECISION'i / KW_DOUBLE / KW_SERIAL / KW_SMALLSERIAL / KW_BIGSERIAL / KW_REAL)l:[0-9]+ __ s:numeric_type_suffix? { /* => data_type */ return { dataType: Array.isArray(t) ? `${t[0].toUpperCase()} ${t[2].toUpperCase()}` : t, length: parseInt(l.join(''), 10), suffix: s }; }
62036205
/ t:(KW_NUMERIC / KW_DECIMAL / KW_INT / KW_INTEGER / KW_SMALLINT / KW_TINYINT / KW_MEDIUMINT / KW_BIGINT / KW_FLOAT / KW_DOUBLE __ 'PRECISION'i / KW_DOUBLE / KW_SERIAL / KW_SMALLSERIAL / KW_BIGSERIAL / KW_REAL) __ s:numeric_type_suffix? __{ /* => data_type */ return { dataType: Array.isArray(t) ? `${t[0].toUpperCase()} ${t[2].toUpperCase()}` : t, suffix: s }; }
62046206

6207+
money_type
6208+
= t:(KW_MONEY) { /* => data_type */ return { dataType: t } }
6209+
62056210
oid_type
62066211
= t:(KW_OID / KW_REGCLASS / KW_REGCOLLATION / KW_REGCONFIG / KW_REGDICTIONARY / KW_REGNAMESPACE / KW_REGOPER / KW_REGOPERATOR / KW_REGPROC / KW_REGPROCEDURE / KW_REGROLE / KW_REGTYPE) { /* => data_type */ return { dataType: t }}
62076212

test/postgres.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,6 +2353,13 @@ describe('Postgres', () => {
23532353
'CREATE TEMP TABLE "test" (id INT, name TEXT)'
23542354
]
23552355
},
2356+
{
2357+
title: 'money type',
2358+
sql: [
2359+
'CREATE TEMP TABLE test (id INT, price MONEY);',
2360+
'CREATE TEMP TABLE "test" (id INT, price MONEY)'
2361+
]
2362+
},
23562363
]
23572364
neatlyNestTestedSQL(SQL_LIST)
23582365
})

0 commit comments

Comments
 (0)