diff --git a/platformics/codegen/templates/database/models/class_name.py.j2 b/platformics/codegen/templates/database/models/class_name.py.j2 index 7945846..bb056dc 100644 --- a/platformics/codegen/templates/database/models/class_name.py.j2 +++ b/platformics/codegen/templates/database/models/class_name.py.j2 @@ -51,6 +51,8 @@ class {{cls.name}}(Entity): {%- elif attr.type == "string" %} {{attr.name}}: Mapped[str] = mapped_column(String, nullable={{ "False" if attr.required else "True"}}{%- if attr.indexed%}, index=True{%- endif %}) {%- elif attr.type == "Array2dFloat" %} + {{attr.name}}: Mapped[JSONB] = mapped_column(JSONB, nullable={{ "False" if attr.required else "True"}}) + {%- elif attr.type == "List1dString" %} {{attr.name}}: Mapped[JSONB] = mapped_column(JSONB, nullable={{ "False" if attr.required else "True"}}) {%- elif attr.type == "integer" %} {{attr.name}}: Mapped[int] = mapped_column(Integer, nullable={{ "False" if attr.required else "True"}}{%- if attr.indexed%}, index=True{%- endif %}) diff --git a/platformics/codegen/templates/graphql_api/helpers/class_name.py.j2 b/platformics/codegen/templates/graphql_api/helpers/class_name.py.j2 index 49b2791..111c8fc 100644 --- a/platformics/codegen/templates/graphql_api/helpers/class_name.py.j2 +++ b/platformics/codegen/templates/graphql_api/helpers/class_name.py.j2 @@ -53,6 +53,8 @@ class {{ cls.name }}GroupByOptions: {{ attr.name }}: Optional[uuid.UUID] = None {%- elif attr.type == "Array2dFloat" %} {{ attr.name }}: Optional[list[list[float]]] = None + {%- elif attr.type == "List1dString" %} + {{ attr.name }}: Optional[list[str]] = None {%- else %} {{ attr.name }}: Optional[{{ attr.type }}] = None {%- endif %} diff --git a/platformics/codegen/templates/graphql_api/types/class_name.py.j2 b/platformics/codegen/templates/graphql_api/types/class_name.py.j2 index 9c62d43..eaab6b1 100644 --- a/platformics/codegen/templates/graphql_api/types/class_name.py.j2 +++ b/platformics/codegen/templates/graphql_api/types/class_name.py.j2 @@ -248,6 +248,8 @@ class {{ cls.name }}(EntityInterface): {{ attr.name }}: {{ getType("str", attr.required) }} {%- elif attr.type == "Array2dFloat" %} {{ attr.name }}: {{ getType("List[List[float]]", attr.required) }} + {%- elif attr.type == "List1dString" %} + {{ attr.name }}: {{ getType("List[str]", attr.required) }} {%- elif attr.is_enum %} {{ attr.name }}: {{ getType(attr.type, attr.required) }} {%- elif attr.type == "integer" %} @@ -373,6 +375,8 @@ Mutation types {{ attr.name }}: {{ getTypeMutation(action, "strawberry.ID", attr.required) }} {%- elif attr.type == "Array2dFloat" %} {{ attr.name }}: {{ getTypeMutation(action, "List[List[float]]", attr.required) }} + {%- elif attr.type == "List1dString" %} + {{ attr.name }}: {{ getTypeMutation(action, "List[str]", attr.required) }} {%- elif attr.is_enum %} {{ attr.name }}: {{ getTypeMutation(action, attr.type, attr.required) }} {%- elif attr.type == "integer" %} diff --git a/platformics/codegen/templates/test_infra/factories/class_name.py.j2 b/platformics/codegen/templates/test_infra/factories/class_name.py.j2 index c14be3d..b6a3af5 100644 --- a/platformics/codegen/templates/test_infra/factories/class_name.py.j2 +++ b/platformics/codegen/templates/test_infra/factories/class_name.py.j2 @@ -79,6 +79,8 @@ class {{ cls.name }}Factory(CommonFactory): {{ field.name }} = fuzzy.FuzzyText() {%- elif field.type == "Array2dFloat" %} {{ field.name }} = factory.LazyAttribute(lambda o: [ [random.uniform(1, 100) for _ in range(5)] ] * random.randint(2, 5) ) + {%- elif field.type == "List1dString" %} + {{ field.name }} = factory.LazyAttribute(lambda o: [ factory.Faker("word").generate() for _ in range(random.randint(2, 5)) ]) {%- elif field.type == "integer" %} {{ field.name }} = fuzzy.FuzzyInteger(1, 1000) {%- elif field.type == "float" %} diff --git a/platformics/codegen/templates/validators/class_name.py.j2 b/platformics/codegen/templates/validators/class_name.py.j2 index 164adf4..134f7bd 100644 --- a/platformics/codegen/templates/validators/class_name.py.j2 +++ b/platformics/codegen/templates/validators/class_name.py.j2 @@ -67,6 +67,8 @@ from typing_extensions import Annotated {{ attr.name }}: Annotated[{{ getTypeValidation(action, "float", attr.required) }}, Field({{getNumericConstraints(attr)}})] {%- elif attr.type == "Array2dFloat" %} {{ attr.name }}: Annotated[{{ getTypeValidation(action, "list[list[float]]", attr.required) }}, Field()] + {%- elif attr.type == "List1dString" %} + {{ attr.name }}: Annotated[{{ getTypeValidation(action, "list[str]", attr.required) }}, Field()] {%- elif attr.is_enum %} {{ attr.name }}: Annotated[{{ getTypeValidation(action, attr.type, attr.required) }}, Field()] {%- elif attr.type == "boolean" %}