fix: inspectdb raise KeyError 'int2' for smallint (#401)
* fix: inspectdb raise KeyError 'int2' for smallint * fix ci error * no ask confirm for ci * docs: update changelog
This commit is contained in:
parent
d6a51bd20e
commit
f5d7d56fa5
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -56,7 +56,9 @@ jobs:
|
|||||||
run: poetry run pip install --upgrade "tortoise-orm>=0.23,<0.24"
|
run: poetry run pip install --upgrade "tortoise-orm>=0.23,<0.24"
|
||||||
- name: Install TortoiseORM develop branch
|
- name: Install TortoiseORM develop branch
|
||||||
if: matrix.tortoise-orm == 'tortoisedev'
|
if: matrix.tortoise-orm == 'tortoisedev'
|
||||||
run: poetry run pip install --upgrade "git+https://github.com/tortoise/tortoise-orm"
|
run: |
|
||||||
|
poetry run pip uninstall -y tortoise-orm
|
||||||
|
poetry run pip install --upgrade "git+https://github.com/tortoise/tortoise-orm"
|
||||||
- name: CI
|
- name: CI
|
||||||
env:
|
env:
|
||||||
MYSQL_PASS: root
|
MYSQL_PASS: root
|
||||||
|
24
CHANGELOG.md
24
CHANGELOG.md
@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
## 0.8
|
## 0.8
|
||||||
|
|
||||||
|
### [0.8.2]**(Unreleased)**
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
- fix: inspectdb raise KeyError 'int2' for smallint. ([#401])
|
||||||
|
|
||||||
|
[#401]: https://github.com/tortoise/aerich/pull/401
|
||||||
|
|
||||||
### [0.8.1](../../releases/tag/v0.8.1) - 2024-12-27
|
### [0.8.1](../../releases/tag/v0.8.1) - 2024-12-27
|
||||||
|
|
||||||
#### Fixed
|
#### Fixed
|
||||||
@ -29,19 +36,18 @@
|
|||||||
[#395]: https://github.com/tortoise/aerich/pull/395
|
[#395]: https://github.com/tortoise/aerich/pull/395
|
||||||
[#394]: https://github.com/tortoise/aerich/pull/394
|
[#394]: https://github.com/tortoise/aerich/pull/394
|
||||||
[#393]: https://github.com/tortoise/aerich/pull/393
|
[#393]: https://github.com/tortoise/aerich/pull/393
|
||||||
[#376]: https://github.com/tortoise/aerich/pull/376
|
[#392]: https://github.com/tortoise/aerich/pull/392
|
||||||
|
[#388]: https://github.com/tortoise/aerich/pull/388
|
||||||
[#386]: https://github.com/tortoise/aerich/pull/386
|
[#386]: https://github.com/tortoise/aerich/pull/386
|
||||||
[#272]: https://github.com/tortoise/aerich/pull/272
|
|
||||||
[#334]: https://github.com/tortoise/aerich/pull/334
|
|
||||||
[#284]: https://github.com/tortoise/aerich/pull/284
|
|
||||||
[#286]: https://github.com/tortoise/aerich/pull/286
|
|
||||||
[#302]: https://github.com/tortoise/aerich/pull/302
|
|
||||||
[#378]: https://github.com/tortoise/aerich/pull/378
|
[#378]: https://github.com/tortoise/aerich/pull/378
|
||||||
[#377]: https://github.com/tortoise/aerich/pull/377
|
[#377]: https://github.com/tortoise/aerich/pull/377
|
||||||
[#271]: https://github.com/tortoise/aerich/pull/271
|
[#376]: https://github.com/tortoise/aerich/pull/376
|
||||||
|
[#334]: https://github.com/tortoise/aerich/pull/334
|
||||||
|
[#302]: https://github.com/tortoise/aerich/pull/302
|
||||||
[#286]: https://github.com/tortoise/aerich/pull/286
|
[#286]: https://github.com/tortoise/aerich/pull/286
|
||||||
[#388]: https://github.com/tortoise/aerich/pull/388
|
[#284]: https://github.com/tortoise/aerich/pull/284
|
||||||
[#392]: https://github.com/tortoise/aerich/pull/392
|
[#272]: https://github.com/tortoise/aerich/pull/272
|
||||||
|
[#271]: https://github.com/tortoise/aerich/pull/271
|
||||||
|
|
||||||
### [0.8.0](../../releases/tag/v0.8.0) - 2024-12-04
|
### [0.8.0](../../releases/tag/v0.8.0) - 2024-12-04
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class Column(BaseModel):
|
|||||||
length = ", ".join(length_parts) + ", "
|
length = ", ".join(length_parts) + ", "
|
||||||
if self.null:
|
if self.null:
|
||||||
null = "null=True, "
|
null = "null=True, "
|
||||||
if self.default is not None:
|
if self.default is not None and not self.pk:
|
||||||
if self.data_type in ("tinyint", "INT"):
|
if self.data_type in ("tinyint", "INT"):
|
||||||
default = f"default={'True' if self.default == '1' else 'False'}, "
|
default = f"default={'True' if self.default == '1' else 'False'}, "
|
||||||
elif self.data_type == "bool":
|
elif self.data_type == "bool":
|
||||||
@ -158,11 +158,11 @@ class Inspect:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def int_field(cls, **kwargs) -> str:
|
def int_field(cls, **kwargs) -> str:
|
||||||
return "{name} = fields.IntField({pk}{index}{comment})".format(**kwargs)
|
return "{name} = fields.IntField({pk}{index}{default}{comment})".format(**kwargs)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def smallint_field(cls, **kwargs) -> str:
|
def smallint_field(cls, **kwargs) -> str:
|
||||||
return "{name} = fields.SmallIntField({pk}{index}{comment})".format(**kwargs)
|
return "{name} = fields.SmallIntField({pk}{index}{default}{comment})".format(**kwargs)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def bigint_field(cls, **kwargs) -> str:
|
def bigint_field(cls, **kwargs) -> str:
|
||||||
|
@ -16,12 +16,13 @@ class InspectPostgres(Inspect):
|
|||||||
@property
|
@property
|
||||||
def field_map(self) -> FieldMapDict:
|
def field_map(self) -> FieldMapDict:
|
||||||
return {
|
return {
|
||||||
|
"int2": self.smallint_field,
|
||||||
"int4": self.int_field,
|
"int4": self.int_field,
|
||||||
"int8": self.int_field,
|
"int8": self.bigint_field,
|
||||||
"smallint": self.smallint_field,
|
"smallint": self.smallint_field,
|
||||||
|
"bigint": self.bigint_field,
|
||||||
"varchar": self.char_field,
|
"varchar": self.char_field,
|
||||||
"text": self.text_field,
|
"text": self.text_field,
|
||||||
"bigint": self.bigint_field,
|
|
||||||
"timestamptz": self.datetime_field,
|
"timestamptz": self.datetime_field,
|
||||||
"float4": self.float_field,
|
"float4": self.float_field,
|
||||||
"float8": self.float_field,
|
"float8": self.float_field,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user