Re:Salesforce enables ‘modify all’ in user profiles
by gknoy on Friday May 17, 2019 @08:33PM
(#19944844)
I'm sorry for being a SQL noob. Can you elaborate on what is wrong with this, and what would be the way to write it without causing the scale of problem described in the OP?
[ Parent
| on HN ]
Re:Salesforce enables ‘modify all’ in user profiles
by fazzone on Friday May 17, 2019 @08:41PM
(#19944883)
The problem is that the condition is parsed as
(user=671156 AND permission=16 AND org=101) OR 102
The right way is to use something like org IN (101, 102)
Re:Salesforce enables ‘modify all’ in user profiles
by jimnotgym on Saturday May 18, 2019 @04:03AM
(#19946298)
There are lots of good answers already posted, but if I can make a further suggestion...
It is often worth running a SELECT on the WHERE clause you are about to use for your UPDATE. That way you can make sure only a limited amount of data comes back before you launch something catastrophic.
Re:Salesforce enables ‘modify all’ in user profiles
by brianwu02 on Friday May 17, 2019 @08:39PM
(#19944870)
the last OR statement "OR 102" will evaluate true.
It should be
UPDATE permissions SET allow = 1 WHERE user=671156 AND permission=16 AND org=101 OR org=102;
Re:Salesforce enables ‘modify all’ in user profiles
by slavik81 on Friday May 17, 2019 @09:36PM
(#19945054)
You and fazzone have posted different answers. I'm a little unclear on which matches the original intent, but your where clause is equivalent to:
(user=671156 AND permission=16 AND org=101) OR (org=102)
Re:Salesforce enables ‘modify all’ in user profiles
by ummonk on Friday May 17, 2019 @09:47PM
(#19945092)
That is still wrong and would apply to everyone in org 102