2

I use DBAccess in my project as ORM for my sqlite database. I have few models such as User, Worker etc. When I perform some actions with instances of these classes, for example:

    var query = User.query().whereWithFormat("login = %@ and password
  = %@", withParameters: [login, password])

I get this error in log console:

    "error >> no such table: _entityRevision" 

Though everything works fine and I get the right DBResultSet after fetching this query. So, what is wrong with this?

Marina
  • 1,177
  • 4
  • 14
  • 27

1 Answers1

1

That is an internal table used to track upgrades to Entities when you change property names and object structures. It is created when we create a new DBAccess database, but as you are using an existing one it does not exist.

You could create the table manually to stop the error?

CREATE TABLE IF NOT EXISTS _entityRevision (entityName TEXT,revision INTEGER);

But we will also make sure that is fixed for the next revision of the software.

However, looking at the code, whenever a DB files is opened, then this block of code is run, so this table should exist. Is the database swapped out during the execution of your application with another file? Or is it read-only?

if (dbHandle) {

      /* create the revision table */
      sqlite3_exec(dbHandle, "CREATE TABLE IF NOT EXISTS _schemaRevision (revision INTEGER);", nil, nil, nil);
      sqlite3_exec(dbHandle, "CREATE TABLE IF NOT EXISTS _entityRevision (entityName TEXT,revision INTEGER);", nil, nil, nil);

}

Thanks Adrian

Adrian_H
  • 1,548
  • 1
  • 14
  • 27