[PUP-8693] Add a compare() function Created: 2018/05/03  Updated: 2018/09/19  Resolved: 2018/08/03

Status: Closed
Project: Puppet
Component/s: Docs
Affects Version/s: None
Fix Version/s: PUP 6.0.0

Type: New Feature Priority: Normal
Reporter: Henrik Lindberg Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: stdlib to pup
Sub-team: Language
Team: Platform Core
Release Notes: New Feature
Release Notes Summary: A {{compare(a,b)}} function has been added that returns -1, 0, or 1 depending on if a is before b, same as b, or after b. The function works with the comparable types: String, Numeric, Semver, Timestamp, and Timespan. For String comparison it is possible to ignore or take case into account.
QA Risk Assessment: Needs Assessment


In PUP-8603, the functions min and max are added. For backwards compatibility reasons they must continue to compare values with unwanted/strange automatic type conversion. In order to give users a sane alternative those functions will accept a lambda to enable taking over the responsibility to compare. To facilitate that, a compare(a,b) function should be added that returns -1, 0, 1 depending on the order of the values.

In addition, when compare is given two strings, it should accept a third Boolean argument to control if string comparison ignores case (true - by default), or not.

Comment by Josh Cooper [ 2018/08/03 ]

Merged to puppet#master in https://github.com/puppetlabs/puppet/commit/274a1e0c35b40a1e3377db3cee0f4ccc78b55a17

Comment by Josh Cooper [ 2018/08/03 ]

Helen Campbell, Thomas Honey could you verify that stdlib contains the deprecation warnings Henrik Lindberg mentioned?

Comment by Josh Cooper [ 2018/08/03 ]

This passed CI awhile ago, resolving.

Generated at Tue Sep 29 23:54:26 PDT 2020 using Jira 8.5.2#805002-sha1:a66f9354b9e12ac788984e5d84669c903a370049.