Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete Type Mapping #64

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

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

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