[Sqlalchemy-tickets] Issue #2993: db.Model without primary key generates a confusing error message
Brought to you by:
zzzeek
|
From: Ling T. <iss...@bi...> - 2014-03-14 18:09:10
|
New issue 2993: db.Model without primary key generates a confusing error message https://bitbucket.org/zzzeek/sqlalchemy/issue/2993/dbmodel-without-primary-key-generates-a Ling Thio: When a model definition does not contain a primary key, the following error message appears: sqlalchemy.exc.InvalidRequestError: Class <class 'XYZ'> does not have a __table__ or __tablename__ specified and does not inherit from an existing table-mapped class. Example: ``` #!python from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy app = Flask(__name__) db = SQLAlchemy(app) class Xyz(db.Model): name = db.Column(db.String(50)) ``` It would be nice if the error message: a) specifically mentions the missing primary key, or b) prints the current error message, with the addition of the possibility of a missing primary key. |