-
-
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
CRM/Logging - Fix various bugs in schema parsing #13441
CRM/Logging - Fix various bugs in schema parsing #13441
Conversation
Can one of the admins verify this patch? |
(Standard links)
|
Jenkins add to whitelist |
This looks promising! @aydun any chance you could take a look at this one? |
Ok, I'll take a look - hopefully later this week. |
That would be great @aydun - thanks. |
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.
Generally looks good, and does what it says. Good to see a test.
getIndexesForTable
is only called from updateLogTableSchema
so looks fairly low impact. Would be good to fix the enum length thing but I don't think it actually causes any failures.
Thanks @aydun! I added some code that should handle enums as well as tests for length/enum changes getting pushed through to log tables. |
@civicrm-builder retest this please |
This fixes a couple of bugs in the schema parsing methods used by Civi's extended logging feature: - CRM_Logging_Schema::getIndexesForTable only queried for constraints, not returning any indexes. - CRM_Logging_Schema::getIndexesForTable returned an array in the form [0 => ['constraint_name' => 'foo']] rather than the expected array of index names (i.e. ['foo']). - CRM_Logging_Schema::columnSpecsOf contained an off-by-one error and a wrongly used substr parameter causing column lengths to include surrounding parenthesis. This would result in a "varchar(42)" column returning a length of "(42)" instead of "42".
Instead of storing permitted enum values in the LENGTH array key when extracting column information, this adds a separate ENUM_VALUES key. When schema differences are calculated for enum columns, this value triggers a change when new permitted values are added.
ef30c9e
to
f34f504
Compare
I'm going to merge this - I feel like feedback has been responded to & test coverage is great. I would also note this code is accessed only when updating logging tables & has pretty reasonable coverage so that gives me some confidence |
Overview
CRM_Logging_Schema
contains a number of helper methods for parsing table schemas. The results are then used to create or alter log tables.Before
Some of these methods contain bugs that produce incorrect or incomplete results:
CRM_Logging_Schema::getIndexesForTable
only queries for constraints, not returning any indexes.CRM_Logging_Schema::getIndexesForTable
returns an array in the form[0 => ['constraint_name' => 'foo']]
, meaning lookups viain_array
won't work.CRM_Logging_Schema::columnSpecsOf
contains an off-by-one error and a wrongly used substr parameter causing column lengths to include surrounding parenthesis. This would result in avarchar(42)
column returning a length of(42)
.After
CRM_Logging_Schema::getIndexesForTable
returns constraints as well as indexes.CRM_Logging_Schema::getIndexesForTable
returns an array in the form of['index1', 'index2', ...]
CRM_Logging_Schema::columnSpecsOf
returns column lengths without surrounding parenthesis.