Update dao.tpl to not make presence of import or export required to add 'where' param
authoreileen <emcnaughton@wikimedia.org>
Mon, 15 Apr 2019 03:25:52 +0000 (13:25 +1000)
committereileen <emcnaughton@wikimedia.org>
Tue, 16 Apr 2019 21:27:07 +0000 (07:27 +1000)
Import & export have been hopelessly overloaded & misued in the code. One reason is that without them
'where' is not present. Logically import & export should have a narrow usage and should not
be a pre-requisite for being available as a search field, in reality not so much.

This simply makes the 'where' field available regardless of the presence of these fields

By doing this we can make the metadata in the Query object able to handle more fields
without special handling (e.g Contribution Recur fields)

CRM/Core/CodeGen/Util/Template.php
xml/templates/dao.tpl

index 66efbc3867872c1d67d3f7609db30fad2ab413f8..ed2eac1cae61d5f975a5875dae798a935f1ec4b5 100644 (file)
@@ -77,6 +77,7 @@ class CRM_Core_CodeGen_Util_Template {
         "\n  }\n}\n" => "\n  }\n\n}\n",
         '=> true,' => '=> TRUE,',
         '=> false,' => '=> FALSE,',
+        'static ::' => 'static::'
       ];
       $contents = str_replace(array_keys($replacements), array_values($replacements), $contents);
       $contents = preg_replace('#(\s*)\\/\\*\\*#', "\n\$1/**", $contents);
index 8e0f26f42d10be32efe8ac63891d5690c9f78fb4..f4e39f4d6765c227a4009ce11a46d179668c41fd 100644 (file)
@@ -116,18 +116,15 @@ class {$table.className} extends CRM_Core_DAO {ldelim}
 
 {if $field.import}
                       'import'    => {$field.import|strtoupper},
-                                                                      'where'     => '{$table.name}.{$field.name}',
-                                      'headerPattern' => '{$field.headerPattern}',
-                                      'dataPattern' => '{$field.dataPattern}',
+
 {/if} {* field.import *}
+  'where'     => '{$table.name}.{$field.name}',
+  {if $field.headerPattern}'headerPattern' => '{$field.headerPattern}',{/if}
+  {if $field.dataPattern}'dataPattern' => '{$field.dataPattern}',{/if}
 {if $field.export}
                       'export'    => {$field.export|strtoupper},
-                                      {if ! $field.import}
-                      'where'     => '{$table.name}.{$field.name}',
-                                      'headerPattern' => '{$field.headerPattern}',
-                                      'dataPattern' => '{$field.dataPattern}',
-              {/if}
 {/if} {* field.export *}
+
 {if $field.rule}
                       'rule'      => '{$field.rule}',
 {/if} {* field.rule *}