capacitor-community / sqlite

Community plugin for native & electron SQLite databases
MIT License
433 stars 106 forks source link

INSERT with a value that contains the keyword "return" breaks #448

Closed mueggi closed 9 months ago

mueggi commented 10 months ago

If you VALUE a value with keyword "return", the INSERT will fail.

To Reproduce

CREATE VIRTUAL TABLE if not exists docToolTextSearch USING fts3(body, id, page);

INSERT INTO docToolTextSearch (body,id,page) VALUES('FLIGHT MANUAL EC 135 T1 CDS   Emergency and Malfunction Procedures   CAUTION INDICATIONS   ENG MANUAL   or   SYSTEM I   SYSTEM II   Conditions/Indications   Engine MANUAL mode has been selected by setting ENG MODE SEL sw from NORM to   MAN   NOTE    If ENG MANUAL comes together with TWIST GRIP refer to TWIST GRIP cau-   tion indication   Following functions of the respective engine are inoperative       automatic acceleration deceleration during power collective changes   N   1    limiter   NORM start is impossible   Procedure   WARNING    OPERATE THE TWIST GRIP WITH GREAT CARE AND AVOID QUICK TWIST   GRIP ROTATIONS   HOLD MIN 10 TORQUE ON THE NORMAL ENGINE TO MAINTAIN   AUTOMATIC CONTROL OF N   RO      The ENG MANUAL mode may be used for training of the FADEC FAIL procedure   After training is completed return to NORM mode   Respective ENG MODE SEL selector sw   Respective TWIST GRIP   ENG MANUAL caution   TWIST GRIP caution   Wait 10 sec before any power variation   Correct operation in NORM mode   NORM   Turn gradually to NEUTRAL   position   Check off   Verify by small collective   movements   3 - 18   APPROVED   Rev 33   ', '5983270909465803','120');

this.sqliteConnection.executeSet(batch, false);

- efb.sqlite3: Error running update_5.sql {"e":{"errorMessage":"ExecuteSet: Failed in execSet : Error: prepareSQL prepare failed rc: 1 message: unrecognized token: \"'FLIGHT MANUAL EC

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context It used to work with version 4.6.1 and now with 5.0.6, it breaks.

jepiqueau commented 9 months ago

@mueggi Since 5.0.5 i have implemented the RETURNING keyword. So may be that the reason

mueggi commented 9 months ago

@jepiqueau Thanks, we will try that. If so, will there be a workaround or do we have to downgrade to 5.0.4?

jepiqueau commented 9 months ago

@mueggi i will have to look d'épée in to it so the best may be to downgrade for a while i am currently working hard on the issue#445 which will take quiet a time to fix it. So this will come later

jepiqueau commented 9 months ago

@mueggi Can you show me the code where you create batch

jepiqueau commented 9 months ago

@mueggi i did this for testing

        let db2: SQLiteDBConnection;
        const retCC = (await this._sqlite.checkConnectionsConsistency()).result;
        let isConn = (await this._sqlite.isConnection("testIssue448")).result;
        if(retCC && isConn) {
          db2 = await this._sqlite.retrieveConnection("testIssue448");
        } else {
          db2 = await this._sqlite
                    .createConnection("testIssue448", false, "no-encryption", 1);
        }
        // open db testNew
        await db2.open();

        const sql448 = `
          CREATE VIRTUAL TABLE if not exists docToolTextSearch USING fts3(body, id, page);
          INSERT INTO docToolTextSearch (body,id,page) VALUES('FLIGHT MANUAL EC 135 T1 CDS   Emergency and Malfunction Procedures   CAUTION INDICATIONS   ENG MANUAL   or   SYSTEM I   SYSTEM II   Conditions/Indications   Engine MANUAL mode has been selected by setting ENG MODE SEL sw from NORM to   MAN   NOTE    If ENG MANUAL comes together with TWIST GRIP refer to TWIST GRIP cau-   tion indication   Following functions of the respective engine are inoperative       automatic acceleration deceleration during power collective changes   N   1    limiter   NORM start is impossible   Procedure   WARNING    OPERATE THE TWIST GRIP WITH GREAT CARE AND AVOID QUICK TWIST   GRIP ROTATIONS   HOLD MIN 10 TORQUE ON THE NORMAL ENGINE TO MAINTAIN   AUTOMATIC CONTROL OF N   RO      The ENG MANUAL mode may be used for training of the FADEC FAIL procedure   After training is completed return to NORM mode   Respective ENG MODE SEL selector sw   Respective TWIST GRIP   ENG MANUAL caution   TWIST GRIP caution   Wait 10 sec before any power variation   Correct operation in NORM mode   NORM   Turn gradually to NEUTRAL   position   Check off   Verify by small collective   movements   3 - 18   APPROVED   Rev 33   ', '5983270909465803','120');
        `;
        ret = await db2.execute(sql448);
        console.log(`sql448 ret: `,ret)
        const batch = [
          { statement: "DROP TABLE docToolTextSearch;",
            values: []},
          { statement: "CREATE VIRTUAL TABLE if not exists docToolTextSearch USING fts3(body, id, page);",
            values: []},
          { statement: "INSERT INTO docToolTextSearch (body,id,page) VALUES (?,?,?);",
            values:['FLIGHT MANUAL EC 135 T1 CDS   Emergency and Malfunction Procedures   CAUTION INDICATIONS   ENG MANUAL   or   SYSTEM I   SYSTEM II   Conditions/Indications   Engine MANUAL mode has been selected by setting ENG MODE SEL sw from NORM to   MAN   NOTE    If ENG MANUAL comes together with TWIST GRIP refer to TWIST GRIP cau-   tion indication   Following functions of the respective engine are inoperative       automatic acceleration deceleration during power collective changes   N   1    limiter   NORM start is impossible   Procedure   WARNING    OPERATE THE TWIST GRIP WITH GREAT CARE AND AVOID QUICK TWIST   GRIP ROTATIONS   HOLD MIN 10 TORQUE ON THE NORMAL ENGINE TO MAINTAIN   AUTOMATIC CONTROL OF N   RO      The ENG MANUAL mode may be used for training of the FADEC FAIL procedure   After training is completed return to NORM mode   Respective ENG MODE SEL selector sw   Respective TWIST GRIP   ENG MANUAL caution   TWIST GRIP caution   Wait 10 sec before any power variation   Correct operation in NORM mode   NORM   Turn gradually to NEUTRAL   position   Check off   Verify by small collective   movements   3 - 18   APPROVED   Rev 33   ', '5983270909465803','120']
          },
        ];
        ret = await db2.executeSet(batch);
        console.log(`batch ret: ${JSON.stringify(ret)}`);
        await this._sqlite.closeConnection("testIssue448");

and it works well both on iOS and Android Simulators

jepiqueau commented 9 months ago

@mueggi look at your code and please close the issue after

mueggi commented 9 months ago

@jepiqueau Your code is working. Thanks for checking it out. We will do some further testing. After we removed the return statements from the scripts, it was working again, but in that case, it seems to be a different issue.