Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Room (AAC): [SQLITE_ERROR] SQL error or missing database (near "group": syntax error)

Following Dao doesn't build in my Android App:

@Dao
interface GroupDao {

    @Insert
    fun insert(group: Group)

    @Query("SELECT * FROM group")
    fun loadAll(): LiveData<List<Group>>
}

When I build the project in Android Studio 3 I get the following error on gradle build step:

:app:kaptDebugKotlin

e: C:\workspaces\SystemicConsensusKotlin\app\build\tmp\kapt3\stubs\debug\de\maxdobler\systemicconsensus\group\GroupDao.java:13: error: There is a problem with the query: [SQLITE_ERROR] SQL error or missing database (near "group": syntax error)

e: public abstract android.arch.lifecycle.LiveData> loadAll();

If I remove the loadAll function everything works like a charm... What is the problem with this function?

like image 653
m43x Avatar asked Aug 10 '17 20:08

m43x


People also ask

How do I fix syntax error at or near?

Error Message SQL ERROR: syntax error at or near. Troubleshooting This should generally be the first step to troubleshoot any SQL syntax error in a large query: iteratively comment out blocks of SQL to narrow down where the problem is. TIP: To make this process easier, change the group by clause to use position references

How to troubleshoot syntax errors in SQL Server?

In some circumstances, the database error message may display extra detail about where the error was raised, which can be helpful in narrowing down where to look. This should generally be the first step to troubleshoot any SQL syntax error in a large query: iteratively comment out blocks of SQL to narrow down where the problem is.

Why am I getting a database error message about an object?

An object does not exist in the database or is not accessible from the current query (eg referencing orders.id when there is no orders table joined in the current query, etc) In some circumstances, the database error message may display extra detail about where the error was raised, which can be helpful in narrowing down where to look.


1 Answers

GROUP is a reserved keyword in SQLite. You cannot name a table (or anything else) GROUP. Use the tableName property on the @Entity annotation to rename the table to something else, then use that table name in your @Query.

like image 134
CommonsWare Avatar answered Jan 19 '23 20:01

CommonsWare