Moodle

MSSQL doesn't allow text or ntext columns in WHERE clause

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.7.7, 1.8.8, 1.9.4
  • Fix Version/s: 1.7.7+, 1.8.9, 1.9.5
  • Component/s: Database SQL/XMLDB
  • Labels:
    None
  • Environment:
    RedHat Linux, Apache 2.2.3, PHP 5.2.8, SQL Server
  • Database:
    Microsoft SQL
  • Difficulty:
    Easy
  • Affected Branches:
    MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE

Description

The data_filter() function in mod/data/filter.php has a SQL query that compares a text (or, in MSSQL, an ntext) column in a WHERE clause. MSSQL doesn't allow ntext columns in a WHERE clause, so the SQL statement throws errors.

Issue Links

Activity

Hide
Lucian DiPeso added a comment -

Here is a patch file for changes I made to mod/data/filter.php to resolve the issue.

Show
Lucian DiPeso added a comment - Here is a patch file for changes I made to mod/data/filter.php to resolve the issue.
Hide
Eloy Lafuente (stronk7) added a comment -

Hi,

resolving as fixed. I've used the cross-db sql_compare_text() function to produce the SQL needed by each DB:

"AND " . sql_compare_text('df.param1', 1) . " = '1'";

Thanks for the report, Lucian! Ciao

Show
Eloy Lafuente (stronk7) added a comment - Hi, resolving as fixed. I've used the cross-db sql_compare_text() function to produce the SQL needed by each DB: "AND " . sql_compare_text('df.param1', 1) . " = '1'"; Thanks for the report, Lucian! Ciao
Hide
Eloy Lafuente (stronk7) added a comment -

Going to backport this fix to 17_STABLE and 18_STABLE.

Show
Eloy Lafuente (stronk7) added a comment - Going to backport this fix to 17_STABLE and 18_STABLE.
Hide
Eloy Lafuente (stronk7) added a comment -

Done. Now the fix is also in those versions.

Show
Eloy Lafuente (stronk7) added a comment - Done. Now the fix is also in those versions.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: