SeaQL / sea-schema

🌿 SQL schema definition and discovery
https://docs.rs/sea-schema
Apache License 2.0
192 stars 40 forks source link

Error generating entity fromSQLite database with decimal type #123

Open cxgreat2014 opened 9 months ago

cxgreat2014 commented 9 months ago

Description

I encountered an issue while attempting to generate an entity from a Django site's SQLite database using the sea-orm-cli. It seems to fail when dealing with the decimal type.

Steps to Reproduce

  1. Create a SQLite table as follows:
CREATE TABLE django_apscheduler_djangojobexecution
(
    id        INTEGER      NOT NULL PRIMARY KEY AUTOINCREMENT,
    status    VARCHAR(50)  NOT NULL,
    run_time  DATETIME     NOT NULL,
    duration  DECIMAL,
    finished  DECIMAL,
    exception VARCHAR(1000),
    traceback TEXT,
    job_id    VARCHAR(255) NOT NULL,
    CONSTRAINT unique_job_executions UNIQUE (job_id, run_time)
);
  1. Execute sea-orm-cli generate entity -v
2024-01-30T11:15:00.907209Z DEBUG sqlx::query: summary="PRAGMA foreign_key_list('django_apscheduler_djangojobexecution')" db.statement="" rows_affected=0 rows_returned=1 elapsed=70.6µs
2024-01-30T11:15:00.907468Z DEBUG sqlx::query: summary="PRAGMA table_info('django_apscheduler_djangojobexecution')" db.statement="" rows_affected=0 rows_returned=8 elapsed=97.6µs
thread 'main' panicked at C:\Users\rustdev\.cargo\registry\src\index.crates.io-6f17d22bba15001f\sea-schema-0.14.2\src\sqlite\def\types.rs:62:42:
index out of bounds: the len is 1 but the index is 1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Error occurs at sea-schema/types.rs:62.

Expected Behavior

Actual Behavior

Reproduces How Often

Always reproducible.

Versions

Additional Information