window is a reserved word in postgresql 8.4+ , but not recognized in postgresql dialect

Issue #2092 resolved
Former user created an issue

Window is a reserved keyword in postgresql 8.4+, accoring to http://www.postgresql.org/docs/8.4/static/sql-keywords-appendix.html. And according to http://www.sqlalchemy.org/docs/core/schema.html#sqlalchemy.schema.Column.init columns given a name of a reserved word (if known by the dialect), should be automatically double quoted. But the code below illustrates that at least up to version 0.6.6, window is not known as a reserved word in the postgresql dialect.

import sqlalchemy sqlalchemy.version metadata=sqlalchemy.MetaData() metadata.bind=sqlalchemy.create_engine('postgresql://test:testpw@localhost/postgres') col=sqlalchemy.Column('window',sqlalchemy.Integer) table=sqlalchemy.Table('testtab',metadata,col) table.create()

this raises: sqlalchemy.exc.ProgrammingError: (ProgrammingError) syntax error at or near "window"
LINE 3: window INTEGER

but metadata.clear() col=sqlalchemy.Column('window',sqlalchemy.Integer,quote=True) table=sqlalchemy.Table('testtab',metadata,col) table.create()

works fine.

Comments (4)

  1. Former user Account Deleted

    Window is a reserved keyword in postgresql 8.4+, accoring to http://www.postgresql.org/docs/8.4/static/sql-keywords-appendix.html.

    And according to http://www.sqlalchemy.org/docs/core/schema.html#sqlalchemy.schema.Column.__init columns given a name of a reserved word (if known by the dialect), should be automatically double quoted. But the code below illustrates that at least up to version 0.6.6, window is not known as a reserved word in the postgresql dialect.

    import sqlalchemy
    metadata=sqlalchemy.MetaData()
    metadata.bind=sqlalchemy.create_engine('postgresql://test:testpw@localhost/postgres')
    col=sqlalchemy.Column('window',sqlalchemy.Integer)
    table=sqlalchemy.Table('testtab',metadata,col)
    table.create()
    

    raises:[BR] sqlalchemy.exc.ProgrammingError: (ProgrammingError) syntax error at or near "window"[BR] LINE 3: window INTEGER

    But

    metadata.clear()
    col=sqlalchemy.Column('window',sqlalchemy.Integer,quote=True)
    table=sqlalchemy.Table('testtab',metadata,col)
    table.create()
    

    works fine

  2. Mike Bayer repo owner
    • changed milestone to 0.6.7

    need to add explcit reserved word list to postgresql/base.py similar to that of mysql/base.py.

  3. Log in to comment