OP-Engineering/op-sqlite

Prepared statement sometimes reuse previous queries / bind sometimes doesn't work properly

SrMouraSilva opened this issue · 4 comments

First, of all, thank you for this awesome library!

Describe the bug
Sometimes, prepared statement reuse previous queries without replace parameters sent by bind, so the same query is runned.

Versions:

  • OS and version: Android 12
  • op-sqlite version: 2.0.13
  • RN version: 0.73.2

Reproducible example

// Open database
const database = open({
  name: `../files/${databaseName}`,
});

// Create statement
const statement = database.prepareStatement(`
    select id_musica, titulo, letra, compositores, midias
      from musica
    where id_musica = ?
`);

// Bind and execute
statement.bind([123]);
console.log(statement.execute());

// Wait a random time, like close a screen and open again
// Bind and execute
statement.bind([321]);
console.log(statement.execute());

// do some iterations, sometimes the error doesn't occurs at first time
// but I don't noticed any pattern :/

I noticed that bind and execute both don't requires await. Is it expected?

thanks for reporting. let me take a look there might be something wrong.

took another look at the code but everything looks correct. I also added another test to the example app and everything seems to be working (failing test highlighted, made it fail just for clarity). Maybe you can create a reproduction repo.

Oscar Franco Screen 000840

Thanks @opsfranco. I will prepare a reproduction repo

Going to close this for now, as I cannot find anything wrong. Feel free to post a reproduction demo and I will re-open it.