On 6/21/14, 8:34 AM, Chung WONG wrote:
> Hi list,
> I am encountering a very strange error and I am scratching my head and
> got no idea what is going on. 
>
> class Line(Base):
>     __tablename__ = 'lines'
>     id = Column(Integer, Sequence('line_id_seq'), primary_key=True)
>
>     start = Column(Geometry('POINT'), nullable=False, *index=False*)
>     *end* = Column(Geometry('POINT'), nullable=False, *index=False*)
>
>
> On creating this table, it threw a strange error:
>
> /sqlalchemy.exc.ProgrammingError: (ProgrammingError) syntax error at
> or near "end"/
> /LINE 1: ...INDEX "idx_lines_end" ON "public"."lines" USING GIST (end)/
> /                                                                   ^/
> / 'CREATE INDEX "idx_lines_end" ON "public"."lines" USING GIST (end)' {}/
>
>
> The created table is :
>
> CREATE TABLE lines
> (
>   id integer NOT NULL,
>   start geometry(Point) NOT NULL,
>   *"end"* geometry(Point) NOT NULL,
>   CONSTRAINT lines_pkey PRIMARY KEY (id)
> )
> WITH (
>   OIDS=FALSE
> );
> ALTER TABLE lines
>   OWNER TO postgres;
>
> CREATE INDEX idx_lines_start
>   ON lines
>   USING gist
>   (start);
>
> It is weird there are quotes surrounding the word *end* , and although
> I have specified *index=False*, for some reason indexs are still
> created automatically.
> Anything other than *end*, such as *end_, end1 *worked perfectly.
> Is end a keyword for *postgis* or *geoalchemy2*?
"end" is likely a reserved word, there's nothing wrong with using it as
a column name as SQLAlchemy will quote it, though the other poster has a
point that it's always better to avoid reserved words if for no other
reason than reducing verbosity.

as far as the Index i don't have an insight on the index being created
or not, if perhaps geoalchemy is involved there, not really sure.    See
if changing the Geometry type to something else temporarily changes things.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to