Skip to content

Commit e62d04f

Browse files
kamrandotpkkoenpunt
authored andcommitted
Make sure that the primary key is stored in lowercase
Often, developers set the column names in different cases for the $primary_key static field in the Model. However, the object for the Model stores column names as lowercase (in $attributes). This causes confusion at times (for example, when checking if "$attributes[$pk]" is set while inserting a new record). This small bit of code makes sure no matter what case the developer sets his primary key ("myPrimaryKey" or "myprimaryKey"), the key will always be stored in all lowercase ("myprimarykey").
1 parent e9c5539 commit e62d04f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/Table.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ private function set_primary_key()
457457
$this->pk[] = $c->inflected_name;
458458
}
459459
}
460+
// make sure the primary key is stored in lowercase
461+
$this->pk = array_map('strtolower', $this->pk);
460462
}
461463

462464
private function set_table_name()

0 commit comments

Comments
 (0)