xnuinside / gino-admin

Admin Panel for GinoORM - ready to up & run (just add your models)
https://gino-admin.readthedocs.io/en/latest/
MIT License
49 stars 9 forks source link

ValueError: invalid literal for int() with base 10: '6, 2' #40

Open ShahriyarR opened 3 years ago

ShahriyarR commented 3 years ago

If in the models you define Numeric type with precision and scale:

class Product(db.Model):
    __tablename__ = 'product'

    id = db.Column(db.BigInteger(), primary_key=True)
    category = db.Column(db.BigInteger(), db.ForeignKey('category.id'))
    name = db.Column(db.String(), unique=True, nullable=False)
    slug = db.Column(db.String(), unique=True, nullable=False)
    description = db.Column(db.Unicode(), nullable=True)
    price = db.Column(db.Numeric(6, 2), nullable=False)
    image = db.Column(db.String(), nullable=True)
    thumbnail = db.Column(db.String(), nullable=True)
    date_added = db.Column(db.DateTime(), nullable=False)

We will get:

Traceback (most recent call last):
  File "/home/shako/REPOS/Learning_FastAPI/Djackets/backend/app/admin.py", line 17, in <module>
    create_admin_app(
  File "/home/shako/REPOS/Learning_FastAPI/Djackets/.venv/lib/python3.9/site-packages/gino_admin/core.py", line 185, in create_admin_app
    return init_admin_app(host, port, db, db_models, config)
  File "/home/shako/REPOS/Learning_FastAPI/Djackets/.venv/lib/python3.9/site-packages/gino_admin/core.py", line 196, in init_admin_app
    add_admin_panel(app, db, db_models, **config)
  File "/home/shako/REPOS/Learning_FastAPI/Djackets/.venv/lib/python3.9/site-packages/gino_admin/core.py", line 129, in add_admin_panel
    extract_models_metadata(db, db_models)
  File "/home/shako/REPOS/Learning_FastAPI/Djackets/.venv/lib/python3.9/site-packages/gino_admin/core.py", line 97, in extract_models_metadata
    column_details = extract_column_data(model_id)
  File "/home/shako/REPOS/Learning_FastAPI/Djackets/.venv/lib/python3.9/site-packages/gino_admin/core.py", line 45, in extract_column_data
    len_ = int(str(column.type).split("(")[1].split(")")[0])
ValueError: invalid literal for int() with base 10: '6, 2'
xnuinside commented 3 years ago

@ShahriyarR, thanks for the report, I will try to fix as soon as possible