Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Releases: xnuinside/omymodels

1.0.0 - Refactoring, Pydantic v2, Pydal, OpenAPI 3, SQLAlchemy 2.0 and more

18 Jan 14:01
01a8391

Choose a tag to compare

[1.0.0] - 2025-01-18

Breaking Changes

  • Dropped support for Python 3.7 and 3.8
  • Minimum required Python version is now 3.9

Added

Pydantic v2 Support

  • New pydantic_v2 models type with native Pydantic v2 syntax
  • Uses X | None instead of Optional[X]
  • Uses dict | list for JSON/JSONB types instead of Json
  • Adds from __future__ import annotations for Python 3.9 compatibility
  • Nullable fields automatically get = None default

OpenAPI 3 (Swagger) Support

  • Generate OpenAPI 3 schemas from DDL: create_models(ddl, models_type="openapi3")
  • Convert OpenAPI 3 schemas to Python models: create_models_from_openapi3(schema)
  • Supports JSON and YAML input (with pyyaml)

Plugin System for Custom Generators

  • register_generator() - register custom generator
  • unregister_generator() - remove custom generator
  • list_generators() - list all available generators
  • Base classes: BaseGenerator, ORMGenerator, DataModelGenerator
  • TypeConverter class for type mappings
  • Entry points support for auto-discovery
  • See examples: example/custom_generator.py, example/extend_builtin_generator.py

Pydantic Improvements

  • Field alias support for invalid Python identifiers
  • Handle Pydantic reserved names (copy, parse_obj, schema, etc.)
  • Support for generated columns (GENERATED ALWAYS AS) with exclude=True
  • table_prefix and table_suffix parameters for class name customization
  • Boolean defaults 0/1 converted to False/True
  • Expanded datetime_now_check with more SQL datetime keywords
  • VARCHAR(n) and CHAR(n) now generate Field(max_length=n) for Pydantic validation (issue #48)

SQLAlchemy 2.0 Support (issue #49)

  • New sqlalchemy_v2 models type with modern SQLAlchemy 2.0 syntax
  • Uses DeclarativeBase instead of deprecated declarative_base()
  • Uses Mapped[T] type annotations for columns
  • Uses mapped_column() instead of Column()
  • Uses X | None union syntax for nullable columns
  • Supports all column types, foreign keys, indexes, and constraints

SQLAlchemy Relationships (issue #47)

  • New relationships parameter for create_models() to generate relationship() with back_populates
  • Automatically generates bidirectional relationships for foreign keys:
    • Parent side (one-to-many): collection attribute pointing to children
    • Child side (many-to-one): attribute pointing to parent
  • Works with both sqlalchemy and sqlalchemy_v2 model types
  • For sqlalchemy_v2: uses Mapped[List[T]] for one-to-many and Mapped[T] for many-to-one

Schema-Separated Model Files (issue #40)

  • New split_by_schema parameter for create_models() to generate separate files per database schema
  • Each schema gets its own file with a schema-specific Base class (e.g., Schema1Base)
  • Tables without explicit schema go to a file with the default Base class
  • Works with both sqlalchemy and sqlalchemy_v2 model types
  • File naming: {schema_name}_{base_filename}.py (e.g., schema1_models.py)

Pydal Model Conversion (issue #30)

  • Convert Pydal table definitions to any supported model type using convert_models()
  • Supports all output formats: SQLAlchemy, SQLAlchemy v2, Gino, Pydantic, Pydantic v2, Dataclass, SQLModel
  • Handles Pydal types: id, string, text, integer, boolean, datetime, date, float, decimal
  • Pydal's id type maps to primary key
  • Pydal's reference table_name type maps to foreign key

SQLModel Improvements

  • Fixed array type generation (issue #66)
  • Arrays now properly generate List[T] with correct SQLAlchemy ARRAY type
  • Added typing_imports support for List import
  • Added pydantic_to_sa_fallback mapping for array element types

MySQL Support

  • Added blob types support: tinyblob, blob, mediumblob, longblob map to bytes (issue #62)

Other

  • Added support for Python 3.12 and 3.13
  • Added tox configuration for local multi-version testing (py39-py313)
  • Added pytest-cov for code coverage reporting

Changed

  • Simplified datetime imports (from datetime import datetime instead of import datetime)
  • Use Any type instead of Json for json/jsonb columns in Pydantic
  • Enum generation now uses functional syntax: Enum(value='Name', names=[...])
  • Updated GitHub Actions workflow with latest action versions (checkout@v4, setup-python@v5)
  • Updated py-models-parser to version 1.0.0
  • Reorganized types module with TypeConverter class

Fixed

  • Fixed dependency conflict with simple-ddl-generator: relaxed table-meta constraint to >=0.1.5 (issue #46)
  • Fixed iterate_over_the_list() modifying list during iteration
  • Fixed meaningless condition in dataclass generator
  • Fixed incorrect column type crash (PR #63)
  • Fixed enums including whitespace in values (issue #69)
  • Fixed boolean values capitalization - now generates True/False instead of true/false (PR #67)
  • Fixed SQLModel array type generation TypeError (issue #66)
  • Fixed MySQL blob types not mapping to bytes (issue #62)
  • Fixed sqlalchemy_core generator missing column names in output
  • Fixed sqlalchemy_core generator not including type name with size (e.g., String(255))
  • Fixed sqlalchemy_core generator ForeignKey positional argument order

Documentation

  • Added ARCHITECTURE.md with project documentation
  • Updated documentation with Pydantic v2 examples

Added support for current_timestamp

13 Oct 06:18

Choose a tag to compare

v0.12.1

Improvements

  1. current_timestamp function processed now same was as "now()" function from ddl

Fixes & possibility to disable snake_case convert

12 Oct 06:51

Choose a tag to compare

v0.12.0

Fixes

  1. Now named arguments always went after positional. Fix for #35

New feature:

  1. Availability to disable auto-name convertion - #36.
    Now, if you want to keep names 1-to-1 as in your DDL file, you can set argument no_auto_snake_case=True and O!MyModels will do nothing with the table or column names.

0.11.1 - small release with improvements

24 Apr 11:08

Choose a tag to compare

v0.11.1

Improvements:

  1. added bytes type to pydantic - #31
  2. parser version updated to the latest

v0.11.0 MSSQL fixes

23 Nov 19:36

Choose a tag to compare

v0.11.0

Fixes:

  1. MSSQL column & tables names in [] now is parsed validly - #28
  2. names like 'users_WorkSchedule' now converted correctly to PascalCase like UsersWorkSchedule

v0.10.0 - Converter improvements, Enums moved to separate model

22 Aug 12:40

Choose a tag to compare

Improvements:

  1. Meta models moved to separate package - https://github.com/xnuinside/table-meta
  2. common module renamed to from_ddl, but anyway please use public API as imports from main module:

from omymodels import create_models or from omymodels import convert_models

Fixes:

  1. Fixed bunch of bugs in converter, but it stil in 'beta'.
  2. Previously you can generate models if was any tables in ddl. Now you can also generate Enum models if in ddl you have only CREATE TYPE statements.
  3. String enums now in any models types will be inherit from (str, Enum)

Features:

  1. Added converter feature to convert one model type to another (excluding SQLAlchemy Core (Tables)).
    Now with more tests for supported models, but still in Beta with bucnh of issues.

v0.9.0 - Beta version of Models converter

14 Aug 22:30

Choose a tag to compare

Features:

  1. Added beta models converter from one type of models to another.
    To use models convertor:
from omymodels import convert_models


models_from = """

class MaterialType(str, Enum):

    article = "article"
    video = "video"


@dataclass
class Material:

    id: int
    title: str
    description: str
    link: str
    type: MaterialType
    additional_properties: Union[dict, list]
    created_at: datetime.datetime
    updated_at: datetime.datetime

"""

result = convert_models(models_from, models_type="gino")
print(result)

where models_type - type of models that you want to get as a result

  1. Now if O!MyModels does not know how to convert type - he just leave it as is.

Fixes:

  1. In Dataclass & Pydantic generators now Decimals & Floats converted to float (previously was int).

v0.8.3 - Fixes for dataclasses & refactoring for future code converter feature

12 Jul 21:09

Choose a tag to compare

v0.8.3

  1. Added fundamental concept of TableMetaModel - class that unifies metadata parsed from different classes/ORM models types/DDLs to one standard to allow easy way convert one models to another
    in next releases it will be used for converter from one type of models to another.
  2. Fixed issue: #18 "NOW() not recognized as now()"
  3. Fixed issue: #19 "Default value of now() always returns same time, use field for dataclass"