-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change DAO's that have 'default' => 'NULL'
into 'default' => NULL
, i.e. true NULL
#21573
Conversation
(Standard links)
|
Interesting. Where this came from was #20476 where in api4 it will set a default value based on this field:
'NULL' it sets it to that, not NULL.
I haven't tried running this anywhere yet to see what happens in practice. |
Wow, tests pass! |
@demeritcowboy you must be losing your touch - green tick - what's with that! |
He he... well it is marked WIP... |
I left a comment on #20476 (comment) to the effect that this seems like it could be quietly and broadly disruptive change even without tests failing. I'm mainly concerned from the experience with CRM-15522 / civicrm/civicrm-packages#79. The string I'm eager to dehackify Civi, so if we can get away with doing this change, I'm all for it, but it should absolutely be done independently and well in advance of the event timezone thing in #20476. @agileware-justin asked me to update this PR to say so. Assuming this is the same stuff as is mixed in 5432709 with unrelated event timezone changes (I'm going to rely on @agileware-fj to verify that), I think the best way forward would be to tidy up this PR with a full explanation (and remove the WIP), do a lot of At that point, #20476 could be rebased and just include the event timezone stuff, and anyone looking to review and test it could have a much better handle on it all. It would also mean that it isn't mixed in with this NULL business, helping everyone diagnose bugs a lot easier. |
6d7690c
to
364fd40
Compare
Ok: It's a good thing. Seriously, I do agree it needs some evaluation not just relying on unit tests. However so far in my analysis and clicking on things I do think it's a different type of string 'NULL' than the ones that have been encountered before and baked into PEAR::DB. Here's a list of where I think it's used besides the api4 usage in #20476. While I haven't looked deeply at all of them I don't think any of them change anything for NULL vs 'NULL', which at least partly explains unit tests.
Yes, this is something to look at. Offhand if the schema default is NULL, and then later passing in NULL gets ignored, then theoretically I'd expect it to end up NULL anyway. But yes something to look at. |
default = 'NULL'
into default = NULL
default = 'NULL'
into default = NULL
'default' => 'NULL'
into 'default' => NULL
, i.e. true NULL
Yeah, I think this overall is good. The only scenario I can actively think of is if a database field is set to default to something other than Under the status quo, going to save a row, leaving that field unspecified, would presumably cause the field to pick up the value |
@@ -198,7 +198,8 @@ class {$table.className} extends CRM_Core_DAO {ldelim} | |||
'permission' => {$field.permission|@print_array}, | |||
{/if} | |||
{if $field.default || $field.default === '0'} | |||
'default' => '{if ($field.default[0]=="'" or $field.default[0]=='"')}{$field.default|substring:1:-1}{else}{$field.default}{/if}', | |||
{capture assign=unquotedDefault}{if ($field.default[0]=="'" or $field.default[0]=='"')}{$field.default|substring:1:-1}{else}{$field.default}{/if}{/capture} | |||
'default' => {if ($unquotedDefault==='NULL')}NULL{else}'{$unquotedDefault}'{/if}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at what you're doing here, and looking back through the history of this file, it seems pretty clear that this was simply an artifact of the XML having NULL
in there and not needing to distinguish between that and a string because Pear::DB cleaned up after us. I'm now enthusiastic about this, but I'm still nervous.
Adding a note that I compared the before and after db schema dumps, with trigger-based logging enabled to see the log tables too, and they're identical. Custom field table creation seems unaffected. |
@demeritcowboy can we get this added to the next CiviCRM RC please? This should help with getting more people involved with testing. Thanks! |
I think what you're asking is for someone to merge this into 5.43 because people are currently testing out 5.43? I could rebase it if there's some consensus it should be backported, but it would still need someone to test/review it BEFORE it gets merged, so I'm not sure the version makes a difference in terms of helping the timezone PR (which would be in 5.44). |
@demeritcowboy let's just keep the ball rolling so things don't stall. |
364fd40
to
5fb0de1
Compare
@agileware-justin I just saw your note in chat which I assume applies to the timezone PR but FYI every PR has a test site that gets autobuilt that can be used by anyone with a github account, and the link to it appears in the first comment by |
@demeritcowboy thanks mate, y'know I've never really looked at what that CiviBot comment was about. It always seems to say the same thing. So when it says this: It means: Good to know 😄 |
We had a chat about this & there was a general feeling this should be safe |
Noice. |
Good chat 😄 |
@demeritcowboy just want to give you a special shout out for your excellent work here, great job and much appreciated. Legend. 👍 👍 👍 👍 👍 |
Overview
It's been a few days since I tried breaking something...