This is a (multiple allowed):
[ ] feature-discussion (RFC)
CakePHP Version: 3.x
I tried to use the Table::findOrCreate method with properties that may contain null values.
Since the properties ($search) are passed to the Query::where method directly, this is not null-safe. The where method translates this to `property_name = null`.
It would be nice to have a null-safe function here.
Since CakePHP has the Automatic IS NULL Creation, we simply could append an ' is' to all keys of the search array before passing it to the Query::where method.
If this enhancement is accepted, I could create a pull request for it.
findOrCreate also uses the search query to bootstrap the entity, but that might not be an issue.
I would rather loop the search key/value pairs and create query expressions. That opens the door to support IN if a value is an array.
Good Idea @thinkingmedia, I will create a pull request soon.
Closing as a pull request is open.
Most helpful comment
findOrCreate also uses the search query to bootstrap the entity, but that might not be an issue.
I would rather loop the search key/value pairs and create query expressions. That opens the door to support
INif a value is an array.