Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-13038

update_record does not work with boolean false

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.4, 1.8.4, 1.9
    • Fix Version/s: 1.9
    • Component/s: Database SQL/XMLDB
    • Labels:
      None
    • Database:
      PostgreSQL
    • Affected Branches:
      MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      I think that this code should work:

      $row = new stdClass;
      $row->id = 1
      $row->boolcolumn = false;
      update_record('sometable', $row);

      but it fails on Postgres with the error "invalid syntax for integer: '''"' because PHP converts false to '', not '0'.

      insert_record works because it uses $db->GetInsertSQL. Why don't we use the corresponding $db->GetUpdateSQL, instead of doing our own incorrect code?

      Looking back through CVS history, I don't think we have ever used GetUpdateSQL.

      Presumably MySQL is more tolerant, which is why this has not shown up before.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              skodak Petr Skoda
              Reporter:
              timhunt Tim Hunt
              Participants:
              Component watchers:
              Andrew Nicols, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                3/Mar/08