-
Notifications
You must be signed in to change notification settings - Fork 715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selecting from a table immediately out of a create table transaction #184
Comments
var ready = false;
function exec(command, vals, callback, errCallback) {
if (Object.prototype.toString.call(vals) === "[object Function]") {
errCallback = callback;
callback = vals;
vals = undefined;
}
if (!ready) {
setTimeout(function (){
exec(command, vals, callback);
}, 100);
} else {
db.transaction(function (tx) {
tx.executeSql(command, vals, callback);
}, errCallback);
}
}
function dbInit() {
db = openDatabase();
db.transaction(function (tx) {
db.executeSql('CREATE TABLE IF NOT EXISTS tbl_settings (key text primary key, data text)');
ready = true;
});
}
dbInit();
// here we can't use tbl_settings via db.transaction
// exec waits until create table transaction is done
exec('select * from tbl_settings where key like ?;', ['key1'], function (tx, res) {
// callback(null, res.rows);
}); |
The |
This issue also shows a deviation from how the Web SQL API works. The CoffeeScript/Javascript should be updated to wait until the database is actually opened before attempting to post the transaction. |
To fix this issue in CoffeeScript/Javascript will take some restructuring. I am planning to work on this in the next 1-2 weeks or so. |
Thank you very much, but what about ddl queries (create/alter, ...)? after database ready we have to wait until these queries become complete. i think its good idea we have two type of commands, first ddl commands that are executed normal and other queries that should honor ddl commands completion. function onDatabaseOpened() {
if (!isDatabaseConfigured) {
executeSql('create table...'); // this is ddl command and runs as normal
}
}
// other section of the app that runs on application startup
executeSql('select * from ...'); // a ddl command is running so this should wait until ddl command is done |
@ghominejad it is a nice idea but I would not bother with it. My idea is that all db operations should be queued until it is possible to execute them. It should just work, like it does when you open a normal Web SQL database! |
yes, you're right, its better idea :) |
Clean separation between SQL tests (which should apply to both Web SQL and this plugin) and plugin-specific tests. Add reproduction of minor bug #204. Move reproduction of #209 to section with plugin-specific tests. Mark some plugin db tests that were added by Mark Oppenheim (mailto:mark.oppenheim@mnetics.co.uk) as "Needed to support some large-scale applications". Test repeatedly open and close db two ways (whether or not to wait for open callback before closing db) Add another test of repeatedly open and delete db (wait for open callback before deleting db) Needed for #184/#204/#209/#210/#211/#213.
CHANGES: - Use per-db state to properly handle transactions requested on a database that is being opened (#184). - Report an error upon attempt to close database multiple times. TEST: - Reproduce BUGs #204/#209 - Expand some existing scenarios - Prepare test suite for upcoming fixes and improvements (#184/#204/#209/#210/#211/#213)
CHANGES: - Use per-db state to properly handle transactions requested on a database that is being opened (#184). - Report an error upon attempt to close database multiple times. TEST: - Reproduce BUGs #204/#209 - Expand some existing scenarios - Prepare test suite for upcoming fixes and improvements (#184/#204/#209/#210/#211/#213)
Hi @ghominejad I have now pushed a quick fix to the I am planning to restructure the CoffeeScript/Javascript to solve some more issues with managing the internal state. |
After creating a table i must wait a few milliseconds until transaction done otherwise i can't use db tables out of this transaction.
Transaction error :
"db":{"openargs":{"name":"mydb"},"dbname":"mydb"},"txlock":true,"readOnly":false,"executes":[]}
I think a sync transaction is very useful.
Then we can use async transactions immediately after that :
The text was updated successfully, but these errors were encountered: