Repository: xnuinside/omymodels (language: python)

Issue:
Add Real type
**Is your feature request related to a problem? Please describe.**
When converting sql type `real` to sqlalchemy, it is changed to `real()` but it should be `sa.Real`

**Describe the solution you'd like**
it should be automatically changed to 'Real'

I'm happy to give this go, and give a PR

V0.2.0 release



Discussion / hints:

Fix patch:
diff --git a/omymodels/models/sqlalchemy/types.py b/omymodels/models/sqlalchemy/types.py
index c21db47..47bfeaf 100644
--- a/omymodels/models/sqlalchemy/types.py
+++ b/omymodels/models/sqlalchemy/types.py
@@ -32,6 +32,7 @@
     "smallint": "sa.SmallInteger",
     "jsonb": "JSONB",
     "uuid": "UUID",
+    "real": "sa.REAL",
 }
 
 types_mapping.update(direct_types)


Test patch:
diff --git a/tests/functional/generator/test_sqlalchemy_core.py b/tests/functional/generator/test_sqlalchemy_core.py
index 1cdd06e..68a5381 100644
--- a/tests/functional/generator/test_sqlalchemy_core.py
+++ b/tests/functional/generator/test_sqlalchemy_core.py
@@ -137,3 +137,31 @@ class Products(Base):
     """
     result = create_models(ddl, models_type="sqlalchemy")["code"]
     assert result == expected
+
+
+def test_real():
+    expected = """import sqlalchemy as sa
+from sqlalchemy.ext.declarative import declarative_base
+
+
+Base = declarative_base()
+
+
+class Measurements(Base):
+
+    __tablename__ = 'measurements'
+
+    id = sa.Column(sa.String(32), primary_key=True)
+    date = sa.Column(sa.TIMESTAMP())
+    value = sa.Column(sa.REAL())
+"""
+
+    ddl = """
+    CREATE TABLE "measurements" (
+        "id" char(32) PRIMARY KEY NOT NULL,
+        "date" timestamp,
+        "value" real,
+    );"""
+
+    result = create_models(ddl, models_type="sqlalchemy")["code"]
+    assert result == expected