]> git.mjollnir.org Git - moodle.git/commitdiff
Adding some outer spaces to returned SQL to avoid wrong
authorstronk7 <stronk7>
Mon, 3 Dec 2007 20:44:03 +0000 (20:44 +0000)
committerstronk7 <stronk7>
Mon, 3 Dec 2007 20:44:03 +0000 (20:44 +0000)
sentences caused by concatenation.

Merged from MOODLE_19_STABLE

lib/dmllib.php

index b9d5c3310de32d2d5bbf10729efed456cf97c5cd..f39bdee385633095f6b20f942f89fce546078cd2 100644 (file)
@@ -1832,7 +1832,7 @@ function sql_concat_join($separator="' '", $elements=array()) {
  *     ... AND ' . sql_isempty('tablename', 'fieldname', true/false, true/false);
  *
  * (see parameters description below)
- * 
+ *
  * @param string $tablename name of the table (without prefix). Not used for now but can be
  *                          necessary in the future if we want to use some introspection using
  *                          meta information against the DB. /// TODO ///
@@ -1845,28 +1845,28 @@ function sql_isempty($tablename, $fieldname, $nullablefield, $textfield) {
 
     global $CFG;
 
-    $sql = $fieldname . " = '' ";
+    $sql = $fieldname . " = ''";
 
     switch ($CFG->dbfamily) {
         case 'mssql':
             if ($textfield) {
-                $sql = sql_compare_text($fieldname) . " = '' ";
+                $sql = sql_compare_text($fieldname) . " = ''";
             }
             break;
         case 'oracle':
             if ($nullablefield) {
-                $sql = $fieldname . " IS NULL ";                     /// empties in nullable fields are stored as
-            } else {                                                 /// NULLs
+                $sql = $fieldname . " IS NULL";                     /// empties in nullable fields are stored as
+            } else {                                                /// NULLs
                 if ($textfield) {
-                    $sql = sql_compare_text($fieldname) . " = ' ' "; /// oracle_dirty_hack inserts 1-whitespace 
-                } else {                                             /// in NOT NULL varchar and text columns so
-                    $sql =  $fieldname . " = ' ' ";                  /// we need to look for that in any situation
+                    $sql = sql_compare_text($fieldname) . " = ' '"; /// oracle_dirty_hack inserts 1-whitespace
+                } else {                                            /// in NOT NULL varchar and text columns so
+                    $sql =  $fieldname . " = ' '";                  /// we need to look for that in any situation
                 }
             }
             break;
     }
 
-    return $sql;
+    return ' ' . $sql . ' '; /// Adding spaces to avoid wrong SQLs due to concatenation
 }
 
 /**
@@ -1886,7 +1886,7 @@ function sql_isempty($tablename, $fieldname, $nullablefield, $textfield) {
  *     ... AND ' . sql_isnotempty('tablename', 'fieldname', true/false, true/false);
  *
  * (see parameters description below)
- * 
+ *
  * @param string $tablename name of the table (without prefix). Not used for now but can be
  *                          necessary in the future if we want to use some introspection using
  *                          meta information against the DB. /// TODO ///
@@ -1897,7 +1897,7 @@ function sql_isempty($tablename, $fieldname, $nullablefield, $textfield) {
  */
 function sql_isnotempty($tablename, $fieldname, $nullablefield, $textfield) {
 
-    return '( NOT ' . sql_isempty($tablename, $fieldname, $nullablefield, $textfield) . ')';
+    return ' ( NOT ' . sql_isempty($tablename, $fieldname, $nullablefield, $textfield) . ') ';
 }
 
 /**