Skip to content

Commit 7269ef9

Browse files
committed
Fixed empty creature abilities being saved
1 parent 0ce0e9e commit 7269ef9

3 files changed

Lines changed: 19 additions & 14 deletions

File tree

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Changelog
99

1010
- Added ``upgrade_classification`` to item attributes.
1111
- Fixed empty creature and item sounds being saved.
12+
- Fixed empty creature abilities being saved.
13+
- Marked more SQLite columns as ``NOT NULL``.
1214

1315
.. 6.0.2
1416

tibiawikisql/models/creature.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
from tibiawikisql import schema
2323
from tibiawikisql.models import abc
24-
from tibiawikisql.utils import (clean_links, int_pattern, parse_boolean, parse_integer, parse_min_max, parse_sounds,
25-
clean_question_mark, strip_code, find_template)
24+
from tibiawikisql.utils import (clean_links, clean_question_mark, find_template, int_pattern, parse_boolean,
25+
parse_integer, parse_min_max, parse_sounds, strip_code)
2626

2727
if TYPE_CHECKING:
2828
from mwparserfromhell.nodes import Template
@@ -66,12 +66,15 @@ def parse_abilities(value):
6666
parsed = mwparserfromhell.parse(value)
6767
ability_list_template = find_template(value, "Ability List")
6868
if not ability_list_template:
69+
name = strip_code(parsed)
6970
return [{
70-
"name": strip_code(parsed),
71+
"name": name,
7172
"element": "no_template",
72-
}]
73+
}] if name else []
7374
abilities = []
7475
for element in ability_list_template.params:
76+
if not element.strip():
77+
continue
7578
ability_template = next(element.value.ifilter_templates(recursive=False), None)
7679
if not ability_template:
7780
abilities.append({

tibiawikisql/schema.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,22 +146,22 @@ class Item(Table):
146146

147147
class ItemSound(Table, table_name="item_sound"):
148148
item_id = Column(ForeignKey(Integer, table="item", column="article_id"), index=True)
149-
content = Column(Text)
149+
content = Column(Text, nullable=False)
150150

151151

152152
class ItemStoreOffer(Table, table_name="item_store_offer"):
153153
item_id = Column(ForeignKey(Integer, table="item", column="article_id"), index=True)
154-
price = Column(Integer)
155-
amount = Column(Integer)
156-
currency = Column(Text)
154+
price = Column(Integer, nullable=False)
155+
amount = Column(Integer, nullable=False)
156+
currency = Column(Text, nullable=False)
157157

158158

159159
class CreatureDrop(Table, table_name="creature_drop"):
160160
creature_id = Column(ForeignKey(Integer, table="creature", column="article_id"), index=True, nullable=False)
161161
item_id = Column(ForeignKey(Integer, table="item", column="article_id"), index=True, nullable=False)
162162
chance = Column(Real)
163-
min = Column(Integer)
164-
max = Column(Integer)
163+
min = Column(Integer, nullable=False)
164+
max = Column(Integer, nullable=False)
165165

166166

167167
class ItemAttribute(Table, table_name="item_attribute"):
@@ -197,7 +197,7 @@ class House(Table):
197197
house_id = Column(Integer, index=True)
198198
title = Column(Text, unique=True, no_case=True)
199199
name = Column(Text, unique=True, no_case=True)
200-
city = Column(Text, index=True)
200+
city = Column(Text, index=True, nullable=False)
201201
street = Column(Text, index=True)
202202
location = Column(Text, index=True)
203203
beds = Column(Integer)
@@ -218,8 +218,8 @@ class Imbuement(Table):
218218
article_id = Column(Integer, primary_key=True)
219219
title = Column(Text, unique=True, index=True)
220220
name = Column(Text, unique=True, index=True)
221-
tier = Column(Text)
222-
type = Column(Text)
221+
tier = Column(Text, nullable=False)
222+
type = Column(Text, nullable=False)
223223
effect = Column(Text)
224224
slots = Column(Text)
225225
version = Column(Text, index=True)
@@ -231,7 +231,7 @@ class Imbuement(Table):
231231
class ImbuementMaterial(Table, table_name="imbuement_material"):
232232
imbuement_id = Column(ForeignKey(Integer, "imbuement", "article_id"), index=True)
233233
item_id = Column(ForeignKey(Integer, "item", "article_id"), index=True)
234-
amount = Column(Integer)
234+
amount = Column(Integer, nullable=False)
235235

236236

237237
class ItemKey(Table, table_name="item_key"):

0 commit comments

Comments
 (0)