Hi everybody, here's a small script using mapper inheritance that fails on my 
machine (SQLAlchemy 0.1.7, Python 2.4.2). The following line at the end of the 
script below causes an error:

firstTry = Post.mapper.get(1)

Whereas the next line works fine
secondTry = Post.mapper.get_by(id=1)

Is it a bug or a mistake on my part? Here's the sample script in case anybody 
wants to test the whole thing:

----------------------------------------------------
from sqlalchemy import *

engine = create_engine('mysql',
        {
            'db':'sqlalchemy',
            'user':'myself',
            'passwd':'mypassword',
            'host':'127.0.0.1'
            
        },
        )

text_items = Table('text_items', engine, 
    Column('id', Integer, primary_key=True),
    Column('text', String)
)

posts = Table('posts', engine,
    Column('id', Integer, ForeignKey("text_items.id"), primary_key=True),
    Column('headline', String)
)

text_items.create()
posts.create()

class TextItem(object):
    pass

class Post(TextItem):
    pass


TextItem.mapper = mapper(TextItem, text_items)
Post.mapper = mapper(Post, posts,
                     inherits=TextItem.mapper,
                     )

post = Post()
post.text = "it pretty much always means no"
post.headline = "maybe"
objectstore.commit()

firstTry = Post.mapper.get(1)
secondTry = Post.mapper.get_by(id=1)

-------------------------------------------
Here's the traceback from the "first try":

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "build\bdist.win32\egg\sqlalchemy\mapping\mapper.py", line 251, in get
  File "build\bdist.win32\egg\sqlalchemy\mapping\query.py", line 43, in get
  File "build\bdist.win32\egg\sqlalchemy\mapping\query.py", line 201, in _get
IndexError: tuple index out of range

The "second try" works fine.

Thanks and cheers, Martin

Schnell und einfach ohne Anschlusswechsel zur Lycos DSL Flatrate wechseln und 3 
Monate kostenlos ab effektiven 5,21 EUR pro Monat im ersten Jahr surfen.
http://www.lycos.de/startseite/online/dsl/index.html?prod=DSL&trackingID=email_footertxt

Reply via email to