Bug #3768 - Could not add a new instance of choice with MySQL 5.0.7b - 5.0.9b

Bug #3768 - Could not add a new instance of choice with MySQL 5.0.7b - 5.0.9b

by Anthony Borrow -
Number of replies: 9
Picture of Core developers Picture of Plugin developers Picture of Testers
With MySQL 5.0 the word 'release' was added to the list of reserved words. This causes an error when attempting to insert records into the mdl_choice table. More information can be found by reading Bug #3768. I have suggested that the column be renamed; however, if someone needs a more immediate fix they can modify the SQL statement and place the word in single quotes and it will work. This could be done by modifying the /lib/datalib.php insert_record function to check for the word 'release' as a column name and then place it within single quotes - after,

/// Execute a dummy query to get an empty recordset
    if (!$rs = $db->Execute('SELECT * FROM '. $CFG->prefix . $table .' WHERE '. $primarykey  .' = \'-1\'')) {
        return false;
    }

My vote would be simply to rename the field and keep the tables SQL compliant.

Peace - Anthony
Average of ratings: -
In reply to Anthony Borrow

Re: Bug #3768 - Could not add a new instance of choice with MySQL 5.0.7b - 5.0.9b

by Bala krishnan -

Thanks, Anthony.

your suggestion for changing the column name for RELEASE colum actually made things simple.

COOL.

Now, My CHOICE module is working fine.

In reply to Bala krishnan

Re: Bug #3768 - Could not add a new instance of choice with MySQL 5.0.7b - 5.0.9b

by Kirsten Ellis -
Is the solution to the Choice problem simply to rename "release" to RELEASE or something else ?
my new moodle download has the same error when creating a choice.
thanks
k
In reply to Kirsten Ellis

Re: Bug #3768 - Could not add a new instance of choice with MySQL 5.0.7b - 5.0.9b

by Ne Nashev -
no - MySql is case-insensetive
In reply to Anthony Borrow

Re: Bug #3768 - may be just enable quoting?

by Ne Nashev -

Why not add column name quoting to function datalib.php->update_record() ?

    foreach ($ddd as $key => $value) {
        $count++;
        // <<-- Nashev: adding $db->nameQuote arround $key to provide updates of mdl_choice.release -->>
        $update .= $db->nameQuote.$key.$db->nameQuote .' = \''. $value .'\'';   // All incoming data is already quoted
        if ($count < $numddd) {
            $update .= ', ';
        }
    }


and adodb-lib.inc.php->_adodb_getinsertsql()
and (if used somewhere) adodb-lib.inc.php->_adodb_getupdatesql()

// <<-- commented by Nashev, to support column mdl_choice.release -->>
//if (strpos($upperfname,' ') !== false)
$fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;
//else
// $fnameq = $upperfname;

In reply to Ne Nashev

Re: Bug #3768

by Nigel Weatherby -
I am a bit suprised at the low priority given to this bug.

I certainly wont be changing the table column name unless its confirmed that this will not break the next version upgrade scripts.

Multiple code changes are similarly out of the question.

Is this definately going to be fixed in the 1.6 release?


In reply to Anthony Borrow

Re: Bug #3768 - Could not add a new instance of choice with MySQL 5.0.7b - 5.0.9b

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
sorry guys! - I've been pretty snowed under! - we're down a couple of developers here and guess who has a large project load!

I've finally committed a fix for this to HEAD - it won't be available via public cvs for a couple of hours, but this will mean it will definately be available in 1.6

the new column name is showresults

thanks!

Dan
In reply to Dan Marsden

Re: Bug #3768 - Could not add a new instance of choice with MySQL 5.0.7b - 5.0.9b

by Dhafer Qahtani -

hello Dan--

first thanks for all your great job on this issue and others. do you have any update?

In reply to Anthony Borrow

Re: Bug #3768 - Could not add a new instance of choice with MySQL 5.0.7b - 5.0.9b

by Mauricio Riveros Barbosa -
Sorry by my "beginner question" but I'm trying to fix this problem:
  1. I opened datalib.php as you mention
  2. I found the  line /// Execute a dummy query to get an empty recordset
  3. But I couldn't find any "release" string to replace...