Skip to content

SQLModel codegen produces syntax errors #302

@NixBiks

Description

@NixBiks

Things to check first

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

Sqlacodegen version

3.0.0rc3

SQLAlchemy version

2.0.23

RDBMS vendor

PostgreSQL

What happened?

The screenshot shows some of the issues.

  1. There are unused imports (can easily be fixed by running ruff after codegen)
  2. Missing imports, i.e. mapped_column.
  3. Syntax error due to a , in line 22.
Screenshot 2023-11-16 at 09 18 05

Database schema for reproducing the bug

CREATE TABLE
  logs (
    timestamp timestamp NOT NULL,
    level text NOT NULL,
    message text NOT NULL,
    schedule_id bigint REFERENCES schedules (id),
    worker_id text,
    run_id text,
    id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY
  );

-- sort by timestamp
CREATE INDEX logs_timestamp_desc_idx ON logs (timestamp DESC);

-- create view of logs
CREATE VIEW logs_view AS
  SELECT
    timestamp,
    level,
    message,
    schedule_id,
    worker_id,
    run_id
  FROM logs
  ORDER BY timestamp DESC;

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions