veekun / pokedex

more than you ever wanted to know about Pokémon
MIT License
1.44k stars 637 forks source link

Strange pokemon_moves.order in Gen 2 & 3 #336

Open magical opened 3 years ago

magical commented 3 years ago

Inspired by #335 i decided to look into whether we had any other messed up order columns in pokemon_moves. Answer: yes. We have several cases where a pokemon learns multiple moves at the same level and those rows have a mix of NULL and non-NULL order. Also the order doesn't start at 1? There's even one pokemon (Muk) where both moves have a NULL order.

select p.identifier as pokemon, vg.identifier as version_group, tmp.* from (select pokemon_id, version_group_id, level, array_agg("order" order by "order") as "order" from pokemon_moves where level != 0 group by pokemon_id, version_group_id, level having count(*) != 1 and not every("order" is not null)) as tmp join pokemon p on tmp.pokemon_id = p.id join version_groups vg on tmp.version_group_id = vg.id order by version_group_id, pokemon_id, level;

Results: https://gist.github.com/magical/589445759d7a7ab159fd2be74f228811