SQL parameter bug introduced by latest changes

Discuss anything related to product development
Post Reply
seasoned_geek
Posts: 208
Joined: Thu Jun 11 2020 12:18 pm

SQL parameter bug introduced by latest changes

Post by seasoned_geek »

Code: Select all

  No OpenGL integration plugin was found, this is only required for programs which use OpenGL.
 Parameter count mismatch
INSERT INTO THEME_INDICATORS( THEME_NAME, INDICATOR, RED, BLUE, GREEN, ALPHA, VISUAL_EFFECT, INDICATOR_ALPHA) VALUES( 'SolarizedLight-sRGB', :indicator, :red, :blue, :green, :alpha, :visualEffect, :indicatorAlpha);
 Parameter count mismatch
INSERT INTO THEME_INDICATORS( THEME_NAME, INDICATOR, RED, BLUE, GREEN, ALPHA, VISUAL_EFFECT, INDICATOR_ALPHA) VALUES( 'SolarizedLight-sRGB', :indicator, :red, :blue, :green, :alpha, :visualEffect, :indicatorAlpha);
 Parameter count mismatch
INSERT INTO THEME_INDICATORS( THEME_NAME, INDICATOR, RED, BLUE, GREEN, ALPHA, VISUAL_EFFECT, INDICATOR_ALPHA) VALUES( 'SolarizedLight-sRGB', :indicator, :red, :blue, :green, :alpha, :visualEffect, :indicatorAlpha);
 Parameter count mismatch
INSERT INTO THEME_INDICATORS( THEME_NAME, INDICATOR, RED, BLUE, GREEN, ALPHA, VISUAL_EFFECT, INDICATOR_ALPHA) VALUES( 'SolarizedLight-sRGB', :indicator, :red, :blue, :green, :alpha, :visualEffect, :indicatorAlpha);
 Parameter count mismatch
INSERT INTO THEME_INDICATORS( THEME_NAME, INDICATOR, RED, BLUE, GREEN, ALPHA, VISUAL_EFFECT, INDICATOR_ALPHA) VALUES( 'SolarizedLight-GenRGB', :indicator, :red, :blue, :green, :alpha, :visualEffect, :indicatorAlpha);
It used to allow for a mix and match. I had to mix and match because of an earlier bug where you could not pass a string in a parameter.

Now it just fails.

barbara
Posts: 387
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: SQL parameter bug introduced by latest changes

Post by barbara »

Can you tell us which SQL driver you are using? Not sure what you are mixing and matching. If you think a few lines of sample code would help, please post them.

Thanks,

Barbara

seasoned_geek
Posts: 208
Joined: Thu Jun 11 2020 12:18 pm

Re: SQL parameter bug introduced by latest changes

Post by seasoned_geek »

I'm building RedDiamond with tip of tip from master in various VMs.

Now I know that this only happens on Ubuntu 18.04. It works on Ubuntu 20.04, 22.04, and Manjaro 21.3. Will be trying Fedora 36 shortly.

Previous version built fine on Ubuntu 18.04 which is what I used for my AppImage.

Here are some snippets. These are from after removing the hard coded string and replacing it with :themeName

Code: Select all

    QSqlDatabase db = QSqlDatabase::database( property( "DB_NAME" ).toString() );

Code: Select all

    cmd = "create table THEME_ATTRIBUTES ("
          "THEME_NAME         TEXT NOT NULL PRIMARY KEY, "
          "USE_INDENT_GUIDES  INT, "
          "HIGHLIGHT_BRACES   INT, "
          "CARET_LINE_VISIBLE INT  "
          ");";

    QSqlQuery query( db );

Code: Select all

    cmd = "create table THEME_INDICATORS("
          "THEME_NAME      TEXT NOT NULL,"
          "INDICATOR       INT DEFAULT -1,"
          "RED             INT DEFAULT -1,"
          "BLUE            INT DEFAULT -1,"
          "GREEN           INT DEFAULT -1,"
          "ALPHA           INT DEFAULT 255,"
          "VISUAL_EFFECT   INT DEFAULT 1,"
          "INDICATOR_ALPHA INT DEFAULT 100,"
          "PRIMARY KEY (THEME_NAME, INDICATOR),"
          "FOREIGN KEY(THEME_NAME) REFERENCES THEME_ATTRIBUTES(THEME_NAME)"
          ");";

    if ( !query.exec( cmd ) )
    {
        qDebug() << query.lastError().text();
        qDebug() << query.lastQuery();
    }



Code: Select all

        cmd = "INSERT INTO THEME_INDICATORS( THEME_NAME, INDICATOR, "
              "RED, BLUE, GREEN, ALPHA, VISUAL_EFFECT, INDICATOR_ALPHA) "
              "VALUES( :themeName, :indicator, "
              ":red, :blue, :green, :alpha, :visualEffect, :indicatorAlpha);";

        
        query.prepare( cmd );

        QColor iColor;

        query.bindValue( ":themeName", theme );
        // search found highlight
        query.bindValue( ":indicator",   INDICATOR_FOUND );

        iColor = QColor( 255, 255, 128, 100 );
        query.bindValue( ":red",   iColor.red() );
        query.bindValue( ":blue",  iColor.blue() );
        query.bindValue( ":green", iColor.green() );
        query.bindValue( ":alpha", iColor.alpha() );

        query.bindValue( ":visualEffect", INDIC_STRAIGHTBOX );
        query.bindValue( ":indicatorAlpha", 100 );

        if ( !query.exec() )
        {
            qDebug() << query.lastError().text();
            qDebug() << query.lastQuery();
        }

seasoned_geek
Posts: 208
Joined: Thu Jun 11 2020 12:18 pm

Re: SQL parameter bug introduced by latest changes

Post by seasoned_geek »

Oh,

forgot to mention, SQLite being used for database.

barbara
Posts: 387
Joined: Sat Apr 04 2015 2:32 am
Contact:

Re: SQL parameter bug introduced by latest changes

Post by barbara »

forgot to mention, SQLite being used for database.
Had an idea which might be relevant. We recently added support for the ODBC plugin and needed to make a few other changes

The driver for SQLite is built into the CsSQL library. When building, CopperSpice will use the vendor provided SQLite implementation ( and not the bundled version ) if it is available. Add the following to your CMake commands to force CS to use the bundled version of SQLite.

Code: Select all

-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE
Barbara

seasoned_geek
Posts: 208
Joined: Thu Jun 11 2020 12:18 pm

Re: SQL parameter bug introduced by latest changes

Post by seasoned_geek »

Did more digging. This is a completely bogus error message.

The Ubuntu 18.04 vm was "cleaned" instead of restored from pristine clone. The SQLite database in ~/.local/share had the old table layout which had two (at least one) fewer columns. The prepare has more columns than the table but the error message says I've provided too many data for the marker variables. It should be throwing "column XXX does not exist."

Post Reply