omymodels icon indicating copy to clipboard operation
omymodels copied to clipboard

Complete Type Mapping

Open rayliverified opened this issue 1 year ago • 9 comments

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]]]]

rayliverified avatar Sep 18 '24 20:09 rayliverified

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

xnuinside avatar Sep 19 '24 00:09 xnuinside

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

rayliverified avatar Sep 19 '24 03:09 rayliverified

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

xnuinside avatar Sep 19 '24 09:09 xnuinside

Reformatted

rayliverified avatar Sep 23 '24 19:09 rayliverified

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

xnuinside avatar Sep 30 '24 04:09 xnuinside

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.

rayliverified avatar Sep 30 '24 05:09 rayliverified

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

xnuinside avatar Sep 30 '24 10:09 xnuinside

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

xnuinside avatar Oct 01 '24 05:10 xnuinside

I think the feature set is complete now with the recent changes I pushed today. Added support for time and date types which need special handling.

Next will be the work on going through the tests.

On Tue, 1 Oct 2024, 12:28 am Iuliia Volkova, @.***> wrote:

@rayliverified https://github.com/rayliverified need to resolve merge request conflicts (they appear after merging your first PR)

— Reply to this email directly, view it on GitHub https://github.com/xnuinside/omymodels/pull/64#issuecomment-2384828736, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEXZO3QIC6IMG7DZPQEHYKTZZIXJNAVCNFSM6AAAAABOOO7I22VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBUHAZDQNZTGY . You are receiving this because you were mentioned.Message ID: @.***>

rayliverified avatar Oct 01 '24 05:10 rayliverified