Using version 0.6.5 under python 2.6.5 even simple augments to
__mapper_args__ variable course errors

E.g.
from sqlalchemy import *
from sqlalchemy.dialects.mysql import *
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class CourseAliases(Base):
    __tablename__ = 'CourseAliases'

    alias            = Column(CHAR(length=7), nullable=False)
    year             = Column(INTEGER())
    course_stream_id = Column(INTEGER(), nullable=False)
    auto_gen         = Column(CHAR(length=1), nullable=False)

    __mapper_args__ = {
        'primary_key': course_stream_id
    }


If I try to import it the resultant errors are

from tables import CourseAliases2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "tables/CourseAliases2.py", line 7, in <module>
    class CourseAliases(Base):
  File "/usr/pkg/lib/python2.6/site-packages/SQLAlchemy-0.6.5-
py2.6.egg/sqlalchemy/ext/declarative.py", line 1231, in __init__
    _as_declarative(cls, classname, cls.__dict__)
  File "/usr/pkg/lib/python2.6/site-packages/SQLAlchemy-0.6.5-
py2.6.egg/sqlalchemy/ext/declarative.py", line 1224, in
_as_declarative
    **mapper_args)
  File "/usr/pkg/lib/python2.6/site-packages/SQLAlchemy-0.6.5-
py2.6.egg/sqlalchemy/orm/__init__.py", line 861, in mapper
    return Mapper(class_, local_table, *args, **params)
  File "/usr/pkg/lib/python2.6/site-packages/SQLAlchemy-0.6.5-
py2.6.egg/sqlalchemy/orm/mapper.py", line 217, in __init__
    self._configure_pks()
  File "/usr/pkg/lib/python2.6/site-packages/SQLAlchemy-0.6.5-
py2.6.egg/sqlalchemy/orm/mapper.py", line 481, in _configure_pks
    if self.primary_key_argument:
  File "/usr/pkg/lib/python2.6/site-packages/SQLAlchemy-0.6.5-
py2.6.egg/sqlalchemy/sql/expression.py", line 1423, in __nonzero__
    raise TypeError("Boolean value of this clause is not defined")
TypeError: Boolean value of this clause is not defined

I know I can add the primary_key=True to a Column but what I actually
wanted to do is make a multiple column primary key

E.g
__mapper_args__ = {
        'primary_key':  [course_stream_id,alias]
    }

this produces a different error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "tables/CourseAliases2.py", line 7, in <module>
    class CourseAliases(Base):
  File "/usr/pkg/lib/python2.6/site-packages/SQLAlchemy-0.6.5-
py2.6.egg/sqlalchemy/ext/declarative.py", line 1231, in __init__
    _as_declarative(cls, classname, cls.__dict__)
  File "/usr/pkg/lib/python2.6/site-packages/SQLAlchemy-0.6.5-
py2.6.egg/sqlalchemy/ext/declarative.py", line 1048, in
_as_declarative
    mapper_args[k] = column_copies.get(v,v)
TypeError: Error when calling the metaclass bases
    unhashable type: 'list'

What am I doing wrong ? I am fairly sure I am only doing what the
documentation says.

Thanks for any help
Royce



-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to