bcgov / bcgov/bcdata_py

bc2pg - use generated identity column for pk instead of serial

オープン
#225 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
32
フォーク
7
平均マージ
12分
マージ済み PR(30日)
14

説明

sqlalchemy creates a sequence for the pk by default. Preferred behaviour for pg 10 and up is to use a generated identity column and implicit sequence.

https://www.postgresql.org/docs/current/ddl-identity-columns.html
https://docs.sqlalchemy.org/en/20/core/defaults.html#identity-ddl

something like this (presuming that translating to `GENERATED BY DEFAULT` is the default, because we are loading data with existing values, it cannot not be `GENERATED ALWAYS`):
```
from sqlalchemy import Identity

...
columns.append(
Column(
column_name,
column_type,
primary_key=True,
Identity(),
comment=column_comments,
)
)
```

Obv, will only work for columns of type integer/bigint.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。