Skip to content

Conversation

@rayliverified
Copy link
Contributor

@rayliverified rayliverified commented Sep 18, 2024

I've added the complete types for MySQL and PostgreSQL. Correct pydantic types are now generated.

CREATE TABLE test_table (
  id INT NOT NULL AUTO_INCREMENT,
  tiny_int_example TINYINT DEFAULT 0,
  small_int_example SMALLINT DEFAULT 0,
  medium_int_example MEDIUMINT DEFAULT 0,
  big_int_example BIGINT DEFAULT 0,
  decimal_example DECIMAL(10, 2) DEFAULT 0.00,
  float_example FLOAT DEFAULT 0,
  double_example DOUBLE DEFAULT 0,
  time_example TIME DEFAULT NULL,
  start_date datetime DEFAULT NULL,
  end_date datetime DEFAULT NULL,
  year_example YEAR DEFAULT NULL,
  char_example CHAR(100) DEFAULT NULL,
  varchar_example VARCHAR(255) DEFAULT NULL,
  tiny_text_example TINYTEXT,
  text_example TEXT,
  medium_text_example MEDIUMTEXT,
  long_text_example LONGTEXT,
  binary_example BINARY(16) DEFAULT NULL,
  varbinary_example VARBINARY(255) DEFAULT NULL,
  tiny_blob_example TINYBLOB,
  blob_example BLOB,
  medium_blob_example MEDIUMBLOB,
  long_blob_example LONGBLOB,
  json_example JSON DEFAULT NULL,
  boolean_example TINYINT(1) DEFAULT 0,
  point_example POINT DEFAULT NULL,
  line_example LINESTRING DEFAULT NULL,
  polygon_example POLYGON DEFAULT NULL,
) ENGINE=InnoDB;
import datetime as datetime
from typing import Any, List, Optional
from pydantic import BaseModel


class TestTable(BaseModel):
    id: int
    tiny_int_example: Optional[int]
    small_int_example: Optional[int] = 0
    medium_int_example: Optional[int] = 0
    big_int_example: Optional[float] = 0
    decimal_example: Optional[float] = 0.00
    float_example: Optional[float] = 0
    double_example: Optional[float] = 0
    time_example: Optional[datetime]
    start_date: Optional[datetime]
    end_date: Optional[datetime]
    year_example: Optional[datetime]
    char_example: Optional[str]
    varchar_example: Optional[str]
    tiny_text_example: Optional[str]
    text_example: Optional[str]
    medium_text_example: Optional[str]
    long_text_example: Optional[str]
    binary_example: Optional[bytes]
    varbinary_example: Optional[bytes]
    tiny_blob_example: Optional[bytes]
    blob_example: Optional[bytes]
    medium_blob_example: Optional[bytes]
    long_blob_example: Optional[bytes]
    json_example: Optional[Any]
    boolean_example: Optional[int] = 0
    point_example: Optional[List[float]]
    line_example: Optional[List[List[float]]]
    polygon_example: Optional[List[List[List[float]]]]

- Add complete list of types.
- Generate types and imports correctly.
@xnuinside
Copy link
Owner

@rayliverified thanks for opening the PR! Can you check issues in flake8 pipeline?

@rayliverified
Copy link
Contributor Author

Looks like it's throwing because it doesn't like the formatting.
What formatter are you using? I'm using PyCharm.

@xnuinside
Copy link
Owner

@rayliverified repo has pre-commit hooks and inside them exist black formatter - https://github.com/xnuinside/omymodels/blob/main/.pre-commit-config.yaml#L3

@rayliverified
Copy link
Contributor Author

Reformatted

@xnuinside
Copy link
Owner

@rayliverified I merged your PR and now here is conflicts, also several previous tests are failed in test run

@rayliverified
Copy link
Contributor Author

We probably need to work together to get the tests working.

I'll work on them once I'm unblocked on the enums.

Meanwhile, I'm writing up some documentation on the changes I made and I'll share that with you so you can review.

@xnuinside
Copy link
Owner

@rayliverified enums released in version 1.7.0 simple-ddl-parser

@xnuinside
Copy link
Owner

@rayliverified need to resolve merge request conflicts (they appear after merging your first PR)

@rayliverified
Copy link
Contributor Author

rayliverified commented Oct 1, 2024 via email

xnuinside added a commit that referenced this pull request Jan 18, 2026
- Expand datetime_now_check to support more SQL datetime keywords
- Add table_prefix/table_suffix parameters for class name customization
- Add support for generated columns (GENERATED ALWAYS AS)
- Add Field alias support for invalid Python identifiers
- Handle Pydantic reserved names (copy, parse_obj, schema, etc.)
- Convert boolean defaults 0/1 to False/True
- Simplify datetime imports (from datetime import datetime)
- Use Any type instead of Json for json/jsonb columns
- Improve array type handling
- Update tests to match new output format

Co-Authored-By: Ray Li <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
xnuinside added a commit that referenced this pull request Jan 18, 2026
- Expand datetime_now_check to support more SQL datetime keywords
- Add table_prefix/table_suffix parameters for class name customization
- Add support for generated columns (GENERATED ALWAYS AS)
- Add Field alias support for invalid Python identifiers
- Handle Pydantic reserved names (copy, parse_obj, schema, etc.)
- Convert boolean defaults 0/1 to False/True
- Simplify datetime imports (from datetime import datetime)
- Use Any type instead of Json for json/jsonb columns
- Improve array type handling
- Update tests to match new output format

Co-Authored-By: Ray Li <[email protected]>
@xnuinside
Copy link
Owner

Hi! sorry for ghosting - didn't have any time for open source :/ I will close your PR because I did a lot of changes in codebase - huge refactoring. I made new PR #72 added you as so-author

@xnuinside xnuinside closed this Jan 18, 2026
xnuinside added a commit that referenced this pull request Jan 18, 2026
- Expand datetime_now_check to support more SQL datetime keywords
- Add table_prefix/table_suffix parameters for class name customization
- Add support for generated columns (GENERATED ALWAYS AS)
- Add Field alias support for invalid Python identifiers
- Handle Pydantic reserved names (copy, parse_obj, schema, etc.)
- Convert boolean defaults 0/1 to False/True
- Simplify datetime imports (from datetime import datetime)
- Use Any type instead of Json for json/jsonb columns
- Improve array type handling
- Update tests to match new output format
- Fix flake8 linting issues

Co-Authored-By: Ray Li <[email protected]>
xnuinside added a commit that referenced this pull request Jan 18, 2026
- Expand datetime_now_check to support more SQL datetime keywords
- Add table_prefix/table_suffix parameters for class name customization
- Add support for generated columns (GENERATED ALWAYS AS)
- Add Field alias support for invalid Python identifiers
- Handle Pydantic reserved names (copy, parse_obj, schema, etc.)
- Convert boolean defaults 0/1 to False/True
- Simplify datetime imports (from datetime import datetime)
- Use Any type instead of Json for json/jsonb columns
- Improve array type handling
- Update tests to match new output format
- Fix flake8 linting issues

Co-authored-by: Ray Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants