Consider the following declarative User model in SQLAlchemy:
class User(Base):
id = Column(Integer, primary_key=True)
username = Column(String(50), unique=True)
email = Column(String(1024), unique=True)
points = Column(Integer, default=0)
achievements = relationship('Achievement',
secondary=achievement_association_table,
backref='users')
reviews = relationship('Review', backref='author', lazy='dynamic')
moderated = Column(Boolean, default=True)
When I do a SELECT * FROM user, I noticed that the query was not returning all of my columns, and showed only the “current_user” column which I can only surmise is a result of using Flask-Login.
Making the query User.query.all() resulted in the following SQL:
SELECT "user".created AS user_created, "user".modified AS user_modified, "user".id AS user_id, "user".username AS user_username, "user".email AS user_email, "user".points AS user_points, "user".moderated AS user_moderated
Can anyone help me understand why this table was created double quoted? None of my other (similarly defined) declarative models exhibit this behavior.
Thanks in advance!
useris a reserved words and thus needs to be quoted.More details about quoted identifiers are in the manual:
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS