-
Notifications
You must be signed in to change notification settings - Fork 106
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
CommitTransaction: cannot commit - no transaction is active #414
Comments
@muuvmuuv the PRAGMA foreign_keys is manager directly by the plugin. Can you share a simple app demonstrating the issue |
What do you mean, I don't need to do this manually while using execute? Isn't this a bit antipattern to be on by default? |
@muuvmuuv Is it in the iOS part of the plugin that you get the error ? Did you set-up a sync table ? Do you have a |
Browser, didn't test on iOS yet, had no time to dig into it further... |
@muuvmuuv are you using typeorm? |
We aren't using any ORM. |
@muuvmuuv Are you also use autosave? look at typeorm issue#9100.
|
@muuvmuuv The autosave = true each time there is a transaction which is committed an export of the database is done to localforage to store in the jeepSqliteStore. If there is a new transaction started during this process there is a chance that you get that message depending also of the size of the database |
@muuvmuuv Can you try with |
Tried Tested 2.3.5, same error, but now it is coming earlier on login when data is written. I will create a REPL now and try to encapsulate it. We have a very large database service with a lot of legacy code, maybe it's just our end. |
Kinda strange, if I reload a few times the errors goes away, I can see that it is running our custom db-revisions step by step but runs into this error after each interation. I wonder if its an async issue. |
@muuvmuuv Are you sure that you do not use BEGIN TRANSACTION, COMMIT TRANSACTION or ROLLBACK TRANSACTION in a sql statement? |
@muuvmuuv are you using |
@muuvmuuv if it is through @capacitor-community/sqlite can you show me the code where you instantiate 'jeep-sqlite' |
Through async init() {
try {
if (isWeb) {
await customElements.whenDefined("jeep-sqlite")
const jeepSqliteElement = document.querySelector("jeep-sqlite")
if (jeepSqliteElement != null) {
await this.sqlite.initWebStore()
}
}
// Migrate cordova database
await this.migrateCordovaDatabase()
// Make sure JavaScript and native connections are in sync
const connection = await this.sqlite.checkConnectionsConsistency()
this.log.debug(LogStack.DatabaseService, "Connection consistent", connection.result)
// Connect to database
const connected = await this.sqlite.isConnection(this.DB_NAME, false)
if (connected.result) {
this.log.info(LogStack.DatabaseService, "Retrieving existing connection...")
this.#database = await this.sqlite.retrieveConnection(this.DB_NAME, false)
} else {
this.log.info(LogStack.DatabaseService, "Creating new DB connection...")
this.#database = await this.sqlite.createConnection(
this.DB_NAME,
false,
"no-encryption",
this.DB_VERSION,
false,
)
}
await this.#database.open()
// Run echo test
await this.sqlite.echo("entergon")
// Execute revisions
const executedRevisions = await this.getRevisions()
const revisionFactory = []
this.environmentInjector.runInContext(() => {
for (const Revision of revisions) revisionFactory.push(new Revision(executedRevisions))
})
for (const revision of revisionFactory) {
await revision.run()
}
} catch (error) {
this.log.error(LogStack.DatabaseService, `Fatal`, error)
throw error
}
} |
We don't use TRANSACTION but |
@muuvmuuv can you modify the first executeSQL which fails by adding the transaction parameter to false. The first error
seems to indicate that you run executeSQL and not executeSet |
@muuvmuuv you may look at ionic7-angular-sqlite-starter to look how i instantiate the plugin and the app through the InitializeAppService |
Setting transaction to false on |
Yeah, followed that at the start but our database service has changed a lot since the start of switching to your lib, so might not seen that explicit parameter declaration |
Thanks a lot of getting this sorted step by step! You are amazing man, good problem solver! :) |
@muuvmuuv the idea of setting transaction to false on any execute, executeSet and run was made for the use with typeOrm. |
@muuvmuuv take care that if you set it to false the execute is made obviously without Transaction process |
Yeah, will keep that in mind, but until now that is fine, we will switch to an ORM in a future version of our app but now its only legacy code so no need to put that energy in. |
@muuvmuuv Ok you are welcome |
Describe the bug
I am doing a simple db.execute
DELETE FROM table;
in the browser and got this since a few release (cannot tell since when, sry). Any idea what could cause this? I do aPRAGMA foreign_keys = OFF;
before (to easier wipe all data in that case). All other SQL execute just fine before.To Reproduce
Steps to reproduce the behavior:
Expected behavior
More detailed errors...
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: