From 71d63f5fc9a575b1e28534a2e245f67819c59c05 Mon Sep 17 00:00:00 2001 From: Tristan Grebot Date: Fri, 15 Mar 2024 12:06:07 +0100 Subject: [PATCH] fix missing headercolor setting in Table dbml generation --- pydbml/classes/table.py | 2 ++ test/test_classes/test_table.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/pydbml/classes/table.py b/pydbml/classes/table.py index 99ab6c7..5022725 100644 --- a/pydbml/classes/table.py +++ b/pydbml/classes/table.py @@ -245,6 +245,8 @@ def dbml(self): result += f'Table {name} ' if self.alias: result += f'as "{self.alias}" ' + if self.header_color: + result += f'[headercolor: {self.header_color}] ' result += '{\n' columns_str = '\n'.join(c.dbml for c in self.columns) result += indent(columns_str) + '\n' diff --git a/test/test_classes/test_table.py b/test/test_classes/test_table.py index 75fda72..586aa15 100644 --- a/test/test_classes/test_table.py +++ b/test/test_classes/test_table.py @@ -422,6 +422,24 @@ def test_dbml_simple(self): }''' self.assertEqual(t.dbml, expected) + def test_header_color_dbml(self): + t = Table('products') + t.header_color = '#C84432' + c1 = Column('id', 'integer') + c2 = Column('name', 'varchar2') + t.add_column(c1) + t.add_column(c2) + s = Database() + s.add(t) + + expected = \ +'''Table "products" [headercolor: #C84432] { + "id" integer + "name" varchar2 +}''' + self.assertEqual(t.dbml, expected) + + def test_schema_dbml(self): t = Table('products', schema="myschema") c1 = Column('id', 'integer')