-
Notifications
You must be signed in to change notification settings - Fork 119
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
PRAGMA table_info throws error #512
Comments
@rkreutzer OK it seems to be that from the implementation of RETURNING mode. In fact you must not use db.query but use db.run command. Which must not producteur the error. As i already said db.query is only for SELECT statements hope this will answer |
I'm using TypeORM in an Ionic/Angular app, so db.run is not a callable unction. |
@rkreutzer In the typeOrm driver QueryRunner starting by
Can you share your code or a simple repro, i am not too much familiar with typeOrm. i am currently busy working on trying to fix the bug "The jeep-sqlite element is not present in the DOM!" for the web part of the plugin to allow this command npx typeorm-ts-node-esm migration:generate. Is this something that you see as beneficial ? |
After more research, backing typeorm to 0.3.17 works. PRAGMA was added to the run method in 0.3.20, and if I delete PRAGMA from CapacitorQueryRunner, it works. As to the migrate:generate question, I don't think that it affects my app. |
@rkreutzer i reproduce the issue, PRAGMA should not be put in the list of the run method in the typeorm driver, it works well for query method. i am looking if i can implemented in the run method. |
@rkreutzer it has been added on last January 3 PR#10273 "resolve circular dependency when using vite" by AlexMesser and proposed by Vorujack in last August the best is perhaps that you question them on this and what are the reason they hadd to had PRAGMA to the list of run method. As i said it is not correct so someone must remove it this will imply quite o lot of changes in my code for no reason as db.query for PRAGMA works well. Can you deal that with them please. |
I created typeorm/typeorm#10687 in the TypeORM repo. |
@rkreutzer thank you for this |
@rkreutzer what you can do meanwhile is to create a const fs = require('fs');
const filePath = './node_modules/typeorm/driver/capacitor/CapacitorQueryRunner.js';
const lineToModify = 61;
const replacementText = ' else if (["INSERT", "UPDATE", "DELETE"].indexOf(command) !== -1) {';
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading file:', err);
return;
}
// Split data by line
const lines = data.split('\n');
// Modify the specific line
if (lines.length >= lineToModify) {
lines[lineToModify - 1] = replacementText; // Line numbers are 1-based
} else {
console.error('Line number to modify is out of range.');
return;
}
// Join lines back together
const modifiedData = lines.join('\n');
// Write the modified data back to the file
fs.writeFile(filePath, modifiedData, 'utf8', (err) => {
if (err) {
console.error('Error writing file:', err);
return;
}
console.log('File modified successfully.');
});
}); add in package.json a script "scripts": {
...
"postinstall": "node ./scripts/modify-typeorm.cjs"
}, and the you run the script npm run postinstall |
Describe the bug
When executing a query "PRAGMA table_info("xxxx");", it throws error "Error: Run: error code 100: another row available"
While there is a workaround to query sqlite_master for the table name, the synchronize function calls PRAGMA table_xinfo, which also fails with the same error.
To Reproduce
Connect to a database and run 'await db.query('PRAGMA table_info("xxxx");')
Expected behavior
No error message is given and it returns an array
Additional context
This was working in version 5.0.6 and likely in version 5.4
The text was updated successfully, but these errors were encountered: