Skip to content

Commit 325d7f7

Browse files
committed
remove uk processing for now
1 parent 11837f7 commit 325d7f7

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

schema_automator/importers/dbml_import_engine.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@
33
from linkml_runtime.linkml_model import SchemaDefinition, ClassDefinition, SlotDefinition
44
from dataclasses import dataclass
55

6+
7+
def _map_dbml_type_to_linkml(dbml_type: str) -> str:
8+
"""
9+
Maps DBML data types to LinkML types.
10+
11+
:param dbml_type: The DBML column type.
12+
:return: Corresponding LinkML type.
13+
"""
14+
type_mapping = {
15+
"int": "integer",
16+
"varchar": "string",
17+
"text": "string",
18+
"float": "float",
19+
"boolean": "boolean",
20+
"date": "date",
21+
"datetime": "datetime",
22+
}
23+
return type_mapping.get(dbml_type.lower(), "string")
24+
25+
626
@dataclass
727
class DbmlImportEngine(ImportEngine):
828
"""
@@ -48,14 +68,14 @@ def convert(
4868
# Handle primary key and unique constraints
4969
primary_key_columns = [col for col in table.columns if col.primary_key]
5070
unique_columns = [col for col in table.columns if col.unique and not col.primary_key]
51-
multi_column_unique_keys = table.indexes # Assuming `indexes` captures multi-column unique keys
71+
# multi_column_unique_keys = table.indexes # Assuming `indexes` captures multi-column unique keys
5272

5373
# Process columns
5474
for column in table.columns:
5575
slot_name = column.name
5676
slot_def = SlotDefinition(
5777
name=slot_name,
58-
range=self._map_dbml_type_to_linkml(column.type),
78+
range=_map_dbml_type_to_linkml(column.type),
5979
description=column.note or f"Column '{slot_name}'",
6080
required=column in primary_key_columns or column.unique,
6181
identifier=column in primary_key_columns, # Mark primary key columns as identifiers
@@ -64,10 +84,10 @@ def convert(
6484
class_def.slots.append(slot_name)
6585
processed_slots.add(slot_name)
6686

67-
# Add multi-column unique keys
68-
for index in multi_column_unique_keys:
69-
if index.unique:
70-
class_def.unique_keys.append([col.name for col in index.columns])
87+
# # Add multi-column unique keys
88+
# for index in multi_column_unique_keys:
89+
# if index.unique:
90+
# class_def.unique_keys.append([col.name for col in index.columns])
7191

7292
# Handle single unique column as primary key if no explicit primary key exists
7393
if not primary_key_columns and len(unique_columns) == 1:
@@ -78,21 +98,3 @@ def convert(
7898
schema.classes[table.name] = class_def
7999

80100
return schema
81-
82-
def _map_dbml_type_to_linkml(self, dbml_type: str) -> str:
83-
"""
84-
Maps DBML data types to LinkML types.
85-
86-
:param dbml_type: The DBML column type.
87-
:return: Corresponding LinkML type.
88-
"""
89-
type_mapping = {
90-
"int": "integer",
91-
"varchar": "string",
92-
"text": "string",
93-
"float": "float",
94-
"boolean": "boolean",
95-
"date": "date",
96-
"datetime": "datetime",
97-
}
98-
return type_mapping.get(dbml_type.lower(), "string")

0 commit comments

Comments
 (0)