Skip to content

Commit

Permalink
add REAL type (#44)
Browse files Browse the repository at this point in the history
* add REAL type

* lint

* fix test (ran locally)
  • Loading branch information
peterdudfield authored Jan 7, 2023
1 parent 5465639 commit ad3d4c8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions omymodels/models/sqlalchemy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"smallint": "sa.SmallInteger",
"jsonb": "JSONB",
"uuid": "UUID",
"real": "sa.REAL",
}

types_mapping.update(direct_types)
28 changes: 28 additions & 0 deletions tests/functional/generator/test_sqlalchemy_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ad3d4c8

Please sign in to comment.