agronholm / agronholm/sqlacodegen

Support PostgreSQL Table Inhertiance

Đang mở
#336 5 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Python
Star
2.4k
Fork
284
Merge trung bình
2 ngày 1 giờ
Pull request đã merge (30 ngày)
1

Mô tả

### Things to check first

- [X] I have searched the existing issues and didn't find my bug already reported there

- [X] I have checked that my bug is still present in the latest release

### Sqlacodegen version

3.0.0rc5

### SQLAlchemy version

2.0.29

### RDBMS vendor

PostgreSQL

### What happened?

When using sqlacodegen to generate ORM classes from an existing database schema, the child table ORM classes that inherit from base tables are not created. This issue occurs when there are tables using SQLAlchemy inheritance.

Is there any way to codegen child tables?

### Database schema for reproducing the bug

Up migrateion to reproduce is like below.

```sql
create schema "test";

CREATE TABLE "test"."base" ("base" integer NOT NULL, PRIMARY KEY ("base") );COMMENT ON TABLE "test"."base" IS E'base';

CREATE TABLE test.sub (
sub_data integer
) INHERITS (test.base);

```

Generated code.
```py
# Using geoalchemy2 0.14.7
from sqlalchemy import Column, Integer, PrimaryKeyConstraint, Table
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column

class Base(DeclarativeBase):
pass

class Base(Base):
__tablename__ = 'base'
__table_args__ = (
PrimaryKeyConstraint('base', name='base_pkey'),
{'comment': 'base', 'schema': 'test'}
)

base: Mapped[int] = mapped_column(Integer, primary_key=True)

t_sub = Table(
'sub', Base.metadata,
Column('base', Integer, nullable=False),
Column('sub_data', Integer),
schema='test'
)

```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.