Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use 'index' as a column name in sqlite?

Is it possible to use index as a column name in sqlite?

When i try to execute this query, it is generate with hibernate/jpa:

select
    metadatait0_.id as id25_,
    metadatait0_.guid as guid25_,
    metadatait0_.index as index25_,
    metadatait0_.library_section_id as library7_25_,
    metadatait0_.metadata_type as metadata4_25_,
    metadatait0_.parent_id as parent5_25_,
    metadatait0_.title as title25_ 
from
    metadata_items metadatait0_

I get the following error:

org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
...
Caused by: java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "index": syntax error)
like image 818
cremersstijn Avatar asked Jan 21 '26 13:01

cremersstijn


1 Answers

Try including column name in square brackets:

metadatait0_.[index] as index25_,
like image 192
Alex Polkhovsky Avatar answered Jan 23 '26 08:01

Alex Polkhovsky