diff --git a/cdd/__init__.py b/cdd/__init__.py index d0f1f16c..05be7985 100644 --- a/cdd/__init__.py +++ b/cdd/__init__.py @@ -8,7 +8,7 @@ from logging import getLogger as get_logger __author__ = "Samuel Marks" -__version__ = "0.0.99rc11" +__version__ = "0.0.99rc12" __description__ = ( "Open API to/fro routes, models, and tests. " "Convert between docstrings, classes, methods, argparse, pydantic, and SQLalchemy." diff --git a/cdd/tests/test_sqlalchemy/test_emit_sqlalchemy_utils.py b/cdd/tests/test_sqlalchemy/test_emit_sqlalchemy_utils.py index 449e7038..ae157153 100644 --- a/cdd/tests/test_sqlalchemy/test_emit_sqlalchemy_utils.py +++ b/cdd/tests/test_sqlalchemy/test_emit_sqlalchemy_utils.py @@ -3,6 +3,7 @@ """ import ast +import json from ast import ( Assign, Call, @@ -165,6 +166,38 @@ def test_param_to_sqlalchemy_column_call_when_foreign_key(self) -> None: gold=node_fk_call, ) + def test_param_to_sqlalchemy_column_call_for_schema_comment(self) -> None: + """Tests that SQLalchemy column is generated with schema as comment""" + run_ast_test( + self, + param_to_sqlalchemy_column_call( + ( + "foo", + { + "doc": "", + "typ": "dict", + "ir": intermediate_repr_no_default_doc, + }, + ), + include_name=False, + ), + gold=Call( + func=Name(id="Column", ctx=Load()), + args=[Name(id="JSON", ctx=Load())], + keywords=[ + keyword( + arg="comment", + value=set_value( + "[schema={}]".format( + json.dumps(intermediate_repr_no_default_doc) + ) + ), + identifier=None, + ) + ], + ), + ) + def test_update_args_infer_typ_sqlalchemy_when_simple_array(self) -> None: """Tests that SQLalchemy can infer the typ from a simple array""" args = []