Fix support for composite primary keys
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 24 Jun 2021 03:24:46 +0000 (15:24 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 24 Jun 2021 03:24:49 +0000 (15:24 +1200)
Fixes what looks like an oversight
https://github.com/civicrm/civicrm-core/commit/022785d8d5d4876aa1211b7adc0d7c31e2995fc5#diff-08ba0d294c1f2e5b9d42e4768aa3b30a10e5128809c590f155c5ac0cc9b2f69cL480-L481

An 'if' was added but the uncondition line left in

The result is that if a composite primary field IS defined
per below an entry for it is incorrectly added to the field
array with just autoincrement set.
`
    <primaryKey>
        <name>contact_timestamp_type</name>
        <field>contact_identifier</field>
        <field>recipient_action_datetime</field>
        <field>event_type</field>
    </primaryKey>
`

CRM/Core/CodeGen/Specification.php

index 4d476550a432971540179e10b58b20daba2eee6b..f2300887972b5bf71b9fce789bce2a08fa7c7341 100644 (file)
@@ -514,7 +514,7 @@ class CRM_Core_CodeGen_Specification {
     if (isset($fields[$name])) {
       $fields[$name]['autoincrement'] = $auto;
     }
-    $fields[$name]['autoincrement'] = $auto;
+
     $primaryKey = [
       'name' => $name,
       'autoincrement' => $auto,