Skip to content

Commit 95f8157

Browse files
committed
This reverts commit 7cc6cea from PR bcit-ci#3968. At the time this seemed logical, but turns out it breaks the ability to create non-PRIMARY composite keys, so ...
1 parent 97d5154 commit 95f8157

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

system/database/DB_forge.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,13 @@ public function drop_database($db_name)
239239
*/
240240
public function add_key($key, $primary = FALSE)
241241
{
242-
if (is_array($key))
242+
// DO NOT change this! This condition is only applicable
243+
// for PRIMARY keys because you can only have one such,
244+
// and therefore all fields you add to it will be included
245+
// in the same, composite PRIMARY KEY.
246+
//
247+
// It's not the same for regular indexes.
248+
if ($primary === TRUE && is_array($key))
243249
{
244250
foreach ($key as $one)
245251
{

user_guide_src/source/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Bug fixes for 3.0.3
1616

1717
- Fixed a bug (#4170) - :doc:`Database <database/index>` method ``insert_id()`` could return an identity from the wrong scope with the 'sqlsrv' driver.
1818
- Fixed a bug (#4179) - :doc:`Session Library <libraries/sessions>` doesn't properly maintain its state after ID regeneration with the 'database' driver on PHP7.
19+
- Fixed a bug (#4173) - :doc:`Database Forge <database/forge>` method ``add_key()`` didn't allow creation of non-PRIMARY composite keys after the "bugfix" for #3968.
1920

2021
Version 3.0.2
2122
=============

0 commit comments

Comments
 (0)