only-cliches/Nano-SQL

Error on drop database and table

gsustalo opened this issue · 5 comments

Which version are you using?
2.3.7

Describe the bug
Dropping tables always return next error:

core.js:9110 ERROR Error: Uncaught (in promise): TypeError: Cannot set property 'count' of undefined

Dropping databases always return next error:

Error: TypeError: Cannot read property 'pkCol' of undefined

Tables are not dropped really in IndexedDB storage. Wherever, when query 'show tables' is submmited, this tables don't are returned

Example
nSQL().dropDatabase("my_db").then(() => { // never }).catch(() => { // ALWAYS!! })

    nSQL('users')
      .query('drop')
      .exec()
      .then(() => {
    // never
}).catch(() => {
    // ALWAYS!! 
})`
m11m commented

I've seen something similar.

Which adapter (or value of mode in db config) are you using?

I'm using 'PERM' mode.
Just like in:
https://nanosql.io/databases.html#creating-a-database

Hi! Did you get any far with this? I'm using 'TEMP' and seeing it as well.

To be more specific, seeing it when dropping a table:
await nSQL(this.tableName).query('drop').exec();

nevf commented

Update: Ok I've had a closer look at my code and I'm not actually using 'drop' after all because it didn't (possibly still doesn't) delete indexes. I'm using 'delete' instead to delete all rows in the table.
++++
No problems using 'drop' in my application.
result = await nSQL( this.dbTableName )).query( 'drop' ).exec()

You could try rebuilding indexes.
const result = await nSQL( this.dbTableName ).query( 'rebuild indexes' ).exec()