Moodle

TEXT comparison in restore breaks correct detection of scales

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9.3
  • Fix Version/s: 1.9.4
  • Component/s: Backup
  • Labels:
    None
  • Environment:
    MSSQL + Oracle
  • Database:
    Microsoft SQL, Oracle
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

When restoring a course, pre-existing scales are searched in target site to be reused. That consists in a CLOB comparison in SQL.

But that fails under MSSQL and Oracle that need a special syntax to compare clobs.

Change SQL to use the helper sql_compare_text() function.

Activity

Hide
Eloy Lafuente (stronk7) added a comment -

Resolving as fixed for 19_STABLE and HEAD. Ciao

Show
Eloy Lafuente (stronk7) added a comment - Resolving as fixed for 19_STABLE and HEAD. Ciao
Hide
Tim Hunt added a comment -

Eloy, I thought that when comparing a TEXT column against a literal string like '$sca->scale', there was no need to apply sql_compare_text to the string. What am I missing here?

Also, in the HEAD version, surely it is nicer code if you use get_records_select, rather than _sql.

Show
Tim Hunt added a comment - Eloy, I thought that when comparing a TEXT column against a literal string like '$sca->scale', there was no need to apply sql_compare_text to the string. What am I missing here? Also, in the HEAD version, surely it is nicer code if you use get_records_select, rather than _sql.
Hide
Eloy Lafuente (stronk7) added a comment -

Well, I use to apply sql_compare_text() to both sides just to guarantee that both sides get the same processing when sizing the string and so on. I remember, for example, one Oracle bug time ago causing spaces to be trimmed in the conversion process. By applying the same (buggy) behaviour to both sides... check will be correct. Ideally, one utf-8 substr() should be enough in the literal part... but.

Well, personally I don't like get_records_select() at all. I love raw SQLs... so it's a matter of preferences. Though I understand your point.

Show
Eloy Lafuente (stronk7) added a comment - Well, I use to apply sql_compare_text() to both sides just to guarantee that both sides get the same processing when sizing the string and so on. I remember, for example, one Oracle bug time ago causing spaces to be trimmed in the conversion process. By applying the same (buggy) behaviour to both sides... check will be correct. Ideally, one utf-8 substr() should be enough in the literal part... but. Well, personally I don't like get_records_select() at all. I love raw SQLs... so it's a matter of preferences. Though I understand your point.
Hide
Tim Hunt added a comment -

OK, that makes sense to me. Closing.

Show
Tim Hunt added a comment - OK, that makes sense to me. Closing.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: