Skip to content

Commit

Permalink
MDL-35155 dml: add unit test which exposes substr problem
Browse files Browse the repository at this point in the history
Previously, when using parameters, substring broke on mssql.
  • Loading branch information
danpoltawski committed Jan 8, 2015
1 parent 48ddb79 commit fa01f2b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/dml/tests/dml_test.php
Expand Up @@ -4026,6 +4026,10 @@ public function test_sql_substring() {
} catch (moodle_exception $e) {
$this->assertInstanceOf('coding_exception', $e);
}

$sql = "SELECT id, ".$DB->sql_substr("name", ":param1 + 1")." AS name FROM {{$tablename}}";
$record = $DB->get_record_sql($sql, array('param1' => 4));
$this->assertEquals(substr($string, 5-1), $record->name);
}

public function test_sql_length() {
Expand Down

0 comments on commit fa01f2b

Please sign in to comment.