Skip to content

Commit 89fbcfb

Browse files
committed
Fix key's item_id not being saved correctly.
1 parent ff2c9b8 commit 89fbcfb

6 files changed

Lines changed: 16 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 7.0.2 (2025-06-09)
4+
5+
- Fix key's `item_id` not being saved correctly.
6+
37
## 7.0.1 (2025-05-19)
48

59
- Add `vocation` and `elemental_bond` to item attributes.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ externally.
1313
If you integrate this into your project or use the generated data, make sure to credit [TibiaWiki](https://tibia.fandom.com) and its contributors.
1414

1515

16-
[![Build Status](https://travis-ci.org/Galarzaa90/tibiawiki-sql.svg?branch=master)](https://travis-ci.org/Galarzaa90/tibiawiki-sql)
1716
[![GitHub (pre-)release](https://img.shields.io/github/release/Galarzaa90/tibiawiki-sql/all.svg)](https://github.com/Galarzaa90/tibiawiki-sql/releases)
1817
[![PyPI](https://img.shields.io/pypi/v/tibiawikisql.svg)](https://pypi.python.org/pypi/tibiawikisql/)
1918
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tibiawikisql.svg)
2019
![PyPI - License](https://img.shields.io/pypi/l/tibiawikisql.svg)
20+
![PyPI - Downloads](https://img.shields.io/pypi/dm/tibiawikisql)
2121

2222
## Requirements
2323
* Python 3.10 or higher

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ classifiers = [
4242
]
4343

4444
[project.urls]
45-
"Homepage" = "https://github.com/Galarzaa90/tibiawiki-sql"
45+
"Homepage" = "https://tibiawiki-sql.readthedocs.io/"
46+
"Documentation" = "https://tibiawiki-sql.readthedocs.io/"
47+
"Repository" = "https://github.com/Galarzaa90/tibiawiki-sql"
48+
"Changelog" = "https://tibiawiki-sql.readthedocs.io/en/stable/changelog/"
49+
"Docker Hub: Repo" = "https://hub.docker.com/repository/docker/galarzaa90/tibiawiki-sql"
4650

4751
[project.scripts]
4852
tibiawikisql = "tibiawikisql.__main__:cli"

tibiawikisql/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
__copyright__ = "Copyright 2025 Allan Galarza"
55

66
__license__ = "Apache 2.0"
7-
__version__ = "7.0.1"
7+
__version__ = "7.0.2"

tibiawikisql/models/item.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import pydantic
55
from pydantic import BaseModel, Field
6-
from pypika import Parameter, Query, Table
6+
from pypika import Parameter, Query, Table, functions as fn
77
from typing_extensions import Self
88

99
from tibiawikisql.api import WikiEntry
@@ -384,7 +384,7 @@ class Key(WikiEntry, WithStatus, WithVersion, RowModel, table=ItemKeyTable):
384384
"""The key's number."""
385385
item_id: int | None = None
386386
"""The article id of the item this key is based on."""
387-
material: str | None = None
387+
material: str
388388
"""The key's material."""
389389
location: str | None
390390
"""The key's location."""
@@ -425,7 +425,7 @@ def insert(self, conn: Connection | Cursor) -> None:
425425
(
426426
Query.from_(item_table)
427427
.select(item_table.article_id)
428-
.where(item_table.title == Parameter(":material"))
428+
.where(item_table.title == fn.Concat(Parameter(":material"), ' Key'))
429429
),
430430
Parameter(":material"),
431431
Parameter(":location"),

tibiawikisql/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ class ItemKeyTable(Table, table_name="item_key"):
302302
article_id = Column(Integer, primary_key=True)
303303
title = Column(Text, unique=True)
304304
number = Column(Integer, unique=True)
305-
item_id = Column(ForeignKey(Integer, "item", "article_id"), index=True)
305+
item_id = Column(ForeignKey(Integer, "item", "article_id"), index=True, nullable=False)
306306
name = Column(Text)
307-
material = Column(Text)
307+
material = Column(Text, nullable=False)
308308
location = Column(Text)
309309
origin = Column(Text)
310310
notes = Column(Text)

0 commit comments

Comments
 (0)