QString QSqlQuery bug 2
Posted: Tue Apr 05 2022 12:16 am
				
				Possibly related to the prepare bug. Ripped my hair out for hours on this one.
yields the following
The "fix" was as follows:
QString gladly took the char buffer and everything display wise handled it just fine. QSqlQuery just gagged on it though.
			Code: Select all
void DefaultSyntax::generateSyntaxMasterFromLexers( QSqlDatabase &db )
{
    QSqlQuery query( db );
    unsigned int lexerCnt = GetLexerCount();
    char lexName[2048];
    qDebug() << "lexerCnt: " << lexerCnt << "\n";
    for ( unsigned int jjj=0; jjj<lexerCnt; jjj++ )
    {
        memset( lexName, '\0', sizeof( lexName ) );
        GetLexerName( jjj, lexName, sizeof( lexName )-1 );
        QString cmd = "INSERT INTO SYNTAX_MASTER (SYN_NAME, RANK) VALUES ( \"%1\", 1);";
        cmd = QStringParser::formatArg( cmd, lexName );
        qDebug() << "cmd: " << cmd << "\n";
        if ( !query.exec( cmd ) )
        {
            qDebug() << query.lastError().text();
            qDebug() << query.lastQuery();
        }
    }
}
Code: Select all
lexerCnt:  132 
cmd:  INSERT INTO SYNTAX_MASTER(SYN_NAME) VALUES( 'a68k'); 
unrecognized token: "'a68k" Unable to execute statement
INSERT INTO SYNTAX_MASTER(SYN_NAME) VALUES( 'a68k');
cmd:  INSERT INTO SYNTAX_MASTER(SYN_NAME) VALUES( 'abaqus'); 
unrecognized token: "'abaqus" Unable to execute statement
INSERT INTO SYNTAX_MASTER(SYN_NAME) VALUES( 'abaqus');
cmd:  INSERT INTO SYNTAX_MASTER(SYN_NAME) VALUES( 'ada'); 
unrecognized token: "'ada" Unable to execute statement
INSERT INTO SYNTAX_MASTER(SYN_NAME) VALUES( 'ada');
cmd:  INSERT INTO SYNTAX_MASTER(SYN_NAME) VALUES( 'apdl'); 
Code: Select all
        QString lexStr = QString::fromLatin1( lexName );
        QString cmd = "INSERT INTO SYNTAX_MASTER(SYN_NAME) VALUES( '%1');";
        cmd = QStringParser::formatArg( cmd, lexStr );
        qDebug() << "cmd: " << cmd << "\n";
QString gladly took the char buffer and everything display wise handled it just fine. QSqlQuery just gagged on it though.