AlaSQL / alasql

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
http://alasql.org
MIT License
7.04k stars 659 forks source link

Error: Can not create table 'test', because it already exists in the database 'db' #144

Closed pasapsi closed 8 years ago

pasapsi commented 9 years ago
 alasql('CREATE localStorage DATABASE IF NOT EXISTS db');
alasql('ATTACH localStorage DATABASE db');
alasql('USE db');
alasql('CREATE TABLE IF NOT EXISTS test')

Calling this request 2 times, and he falls in error. obtained condition is not triggered until the end of the table inside?

alasql('CREATE TABLE IF NOT EXISTS test')
agershun commented 9 years ago

The worst thing - I could not reproduce this error. I catched it once, but now can not reproduce it. Can you look at this test file

https://github.com/agershun/alasql/blob/develop/test/test267.js

What should be changed in this file to brake AlaSQL?

pasapsi commented 9 years ago

in tests written. Check. And if it is 2 times cause an error :(

    alasql('CREATE localStorage DATABASE IF NOT EXISTS db');
    alasql('ATTACH localStorage DATABASE db');
    alasql('USE db');
    alasql('CREATE TABLE IF NOT EXISTS test');
    alasql('CREATE localStorage DATABASE IF NOT EXISTS db');
    alasql('ATTACH localStorage DATABASE db');
    alasql('USE db');
    alasql('CREATE TABLE IF NOT EXISTS test');
agershun commented 9 years ago

Victor, hi. Unfortunately, I cannot reproduce this error. Could you write me at agershun at gmail.com, and we can discuss it by the phone or skype.

pasapsi commented 9 years ago

This card is no longer the errors that occurred in previous versions, fix :+1:

SrMordred commented 9 years ago

On: http://alasql.org/console/?help this commands execute on first time and fail after: create table if not exists teste( id int(11) )

SrMordred commented 9 years ago

Still having problems with this issue. Calling it with: var db = new alasql.Database(); db.exec("create table if not exists teste( id int(11) )", [], function(data){console.log("Hello");} ); db.exec("create table if not exists teste( id int(11) )", [], function(data){console.log("Hello");} );

Second callback are never called.

mathiasrw commented 8 years ago

Please have a look at this example:

alasql.promise([
    'CREATE FILESTORAGE DATABASE IF NOT EXISTS test1("./test1.json")', 
    'ATTACH FILESTORAGE DATABASE test1("./test1.json")', 
    'USE test1', 
    'CREATE TABLE IF NOT EXISTS `preferences` (`id` int(11) NOT NULL, `tab` varchar(45) DEFAULT NULL, `tab_id` int(11))', 
    'INSERT INTO `preferences` (`id`, `tab`, `tab_id`) VALUES (1, "where", 1), (2, "when", 8)',
    //'DELETE FROM preferences WHERE id = 1',    
    'SELECT * FROM preferences'    
]).then(function(res){
    console.log('Result from last query:',res)
}).catch(function(reason){
    console.trace(reason)
})

will only work with the version of alasql that is not yet released (0.2.5)


Im closing the issue. Please reopen if you have any questions