mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Don't set autoincrement for ids with zeroes. Test included. #580
This commit is contained in:
parent
98dcc613e2
commit
7d7fcc74c8
2 changed files with 19 additions and 2 deletions
|
@ -923,7 +923,7 @@ class MoveMetaCategory(TableBase):
|
||||||
u"""Very general categories that loosely group move effects."""
|
u"""Very general categories that loosely group move effects."""
|
||||||
__tablename__ = 'move_meta_categories'
|
__tablename__ = 'move_meta_categories'
|
||||||
__singlename__ = 'move_meta_category'
|
__singlename__ = 'move_meta_category'
|
||||||
id = Column(Integer, primary_key=True, nullable=False,
|
id = Column(Integer, primary_key=True, nullable=False, autoincrement=False,
|
||||||
info=dict(description="A numeric ID"))
|
info=dict(description="A numeric ID"))
|
||||||
identifier = Column(Unicode(32), nullable=False, index=True, unique=True,
|
identifier = Column(Unicode(32), nullable=False, index=True, unique=True,
|
||||||
info=dict(description="An identifier", format='identifier'))
|
info=dict(description="An identifier", format='identifier'))
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
from nose.tools import *
|
from nose.tools import *
|
||||||
import unittest
|
import unittest
|
||||||
from sqlalchemy.orm import aliased
|
from sqlalchemy.orm import aliased
|
||||||
|
from sqlalchemy.orm.exc import NoResultFound
|
||||||
|
|
||||||
from pokedex.db import connect, tables
|
from pokedex.db import connect, tables, util
|
||||||
|
|
||||||
def test_encounter_slots():
|
def test_encounter_slots():
|
||||||
# Encounters have a version, which has a version group; encounters also
|
# Encounters have a version, which has a version group; encounters also
|
||||||
|
@ -22,3 +23,19 @@ def test_encounter_slots():
|
||||||
|
|
||||||
assert_equal(sanity_q.count(), 0,
|
assert_equal(sanity_q.count(), 0,
|
||||||
"Encounter slots all match the encounters they belong to")
|
"Encounter slots all match the encounters they belong to")
|
||||||
|
|
||||||
|
def test_nonzero_autoincrement_ids():
|
||||||
|
"""Check that autoincrementing ids don't contain zeroes
|
||||||
|
|
||||||
|
MySQL doesn't like these, see e.g. bug #580
|
||||||
|
"""
|
||||||
|
|
||||||
|
session = connect()
|
||||||
|
for cls in tables.mapped_classes:
|
||||||
|
if 'id' in cls.__table__.c:
|
||||||
|
if cls.__table__.c.id.autoincrement:
|
||||||
|
@raises(NoResultFound)
|
||||||
|
def nonzero_id(cls):
|
||||||
|
util.get(session, cls, id=0)
|
||||||
|
nonzero_id.description = "No zero id in %s" % cls.__name__
|
||||||
|
yield nonzero_id, cls
|
||||||
|
|
Loading…
Reference in a new issue