From 9bfee74a99ae01eeb74ab76abd95676c5e0f02d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= Date: Sun, 17 Apr 2022 17:11:13 +0200 Subject: [PATCH] Fix parsing of float fields with scale digits --- scripts/ddl2cpp | 4 +++- tests/scripts/ddl2cpp_sample_good.sql | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index e0b580fe..503721f6 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -198,7 +198,8 @@ ddlType = ( ) ddlUnsigned = pp.CaselessLiteral("UNSIGNED").setResultsName("isUnsigned") -ddlWidth = ddlLeft + pp.Word(pp.nums) + ddlRight +ddlDigits = "," + pp.Word(pp.nums) +ddlWidth = ddlLeft + pp.Word(pp.nums) + pp.Optional(ddlDigits) + ddlRight ddlTimezone = ( (pp.CaselessLiteral("with") | pp.CaselessLiteral("without")) + pp.CaselessLiteral("time") @@ -363,6 +364,7 @@ def testTable(): text = """ CREATE TABLE "public"."dk" ( "id" int8 NOT NULL DEFAULT nextval('dk_id_seq'::regclass), + "strange" NUMERIC(314, 15), "last_update" timestamp(6) DEFAULT now(), PRIMARY KEY (id) ) diff --git a/tests/scripts/ddl2cpp_sample_good.sql b/tests/scripts/ddl2cpp_sample_good.sql index ac6b048c..cf96ca2e 100644 --- a/tests/scripts/ddl2cpp_sample_good.sql +++ b/tests/scripts/ddl2cpp_sample_good.sql @@ -29,6 +29,7 @@ CREATE TABLE tab_foo delta varchar(255), _epsilon bigint, `omega` double, + some_number NUMERIC(314,15), CONSTRAINT uc_delta UNIQUE (delta, _epsilon) ); @@ -39,4 +40,3 @@ CREATE TABLE tab_bar gamma bool NOT NULL, delta int ); -