mirror of
https://github.com/PokeAPI/pokeapi
synced 2025-02-16 12:38:25 +00:00
Use JSONField instead of CharField for sprites
The models affected were PokemonFormSprites and ItemSprites. This was done to ensure they are properly returned when querying those tables with Hasura.
This commit is contained in:
parent
0dcaf0d0a0
commit
76f7a340e6
3 changed files with 26 additions and 6 deletions
|
@ -499,9 +499,7 @@ def _build_items():
|
|||
|
||||
item_sprites = "items/{0}"
|
||||
sprites = {"default": file_path_or_none(item_sprites.format(file_name))}
|
||||
yield ItemSprites(
|
||||
id=int(info[0]), item_id=int(info[0]), sprites=json.dumps(sprites)
|
||||
)
|
||||
yield ItemSprites(id=int(info[0]), item_id=int(info[0]), sprites=sprites)
|
||||
|
||||
build_generic((ItemSprites,), "items.csv", csv_record_to_objects)
|
||||
|
||||
|
@ -2024,7 +2022,7 @@ def _build_pokemons():
|
|||
),
|
||||
}
|
||||
yield PokemonFormSprites(
|
||||
id=int(info[0]), pokemon_form_id=int(info[0]), sprites=json.dumps(sprites)
|
||||
id=int(info[0]), pokemon_form_id=int(info[0]), sprites=sprites
|
||||
)
|
||||
|
||||
build_generic((PokemonFormSprites,), "pokemon_forms.csv", csv_record_to_objects)
|
||||
|
|
22
pokemon_v2/migrations/0016_auto_20231126_1258.py
Normal file
22
pokemon_v2/migrations/0016_auto_20231126_1258.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 3.1.14 on 2023-11-26 12:58
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("pokemon_v2", "0015_auto_20231121_1209"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="itemsprites",
|
||||
name="sprites",
|
||||
field=models.JSONField(),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="pokemonformsprites",
|
||||
name="sprites",
|
||||
field=models.JSONField(),
|
||||
),
|
||||
]
|
|
@ -882,7 +882,7 @@ class ItemGameIndex(HasItem, HasGeneration, HasGameIndex):
|
|||
|
||||
|
||||
class ItemSprites(HasItem):
|
||||
sprites = models.CharField(max_length=1000)
|
||||
sprites = models.JSONField()
|
||||
|
||||
|
||||
####################
|
||||
|
@ -1716,7 +1716,7 @@ class PokemonFormName(HasPokemonForm, IsName):
|
|||
|
||||
|
||||
class PokemonFormSprites(HasPokemonForm):
|
||||
sprites = models.CharField(max_length=1000)
|
||||
sprites = models.JSONField()
|
||||
|
||||
|
||||
class PokemonGameIndex(HasPokemon, HasGameIndex, HasVersion):
|
||||
|
|
Loading…
Add table
Reference in a new issue