MDL-73112 reportbuilder: improve handling of concatenated columns.
This change overcomes limitations in certain DB engines (such as MySQL[1]) which can lead to truncation of data when applying group concatenation to columns. Ensure we account for that by validating that we are able to extract the expected number of fields from each concatenated value. [1] https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_group_concat_max_len
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
||||
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core_reportbuilder/report",["exports","core_reportbuilder/local/events","core_reportbuilder/local/selectors","core_table/dynamic","core_table/local/dynamic/selectors"],function(a,b,c,d,e){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=g(b);c=g(c);e=g(e);function f(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;f=function(){return a};return a}function g(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=f();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var g=d?Object.getOwnPropertyDescriptor(a,e):null;if(g&&(g.get||g.set)){Object.defineProperty(c,e,g)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function h(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function i(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var i=a.apply(b,c);function f(a){h(i,d,e,f,g,"next",a)}function g(a){h(i,d,e,f,g,"throw",a)}f(void 0)})}}var j={COLLAPSED:"collapsed",EXPANDED:"show",ICONUP:"fa-angle-up",ICONDOWN:"fa-angle-down"},k=!1,l=function(){if(k){return}document.addEventListener(b.tableReload,function(){var a=i(regeneratorRuntime.mark(function a(b){var f,g,h,i;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:g=b.target.closest(c.regions.report);if(!(null===g)){a.next=3;break}return a.abrupt("return");case 3:h=g.querySelector(e.main.region);i=(null===(f=b.detail)||void 0===f?void 0:f.preservePagination)?null:1;a.next=7;return(0,d.setPageNumber)(h,i,!1).then(d.refreshTableContent);case 7:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}());document.addEventListener("click",function(a){var b=a.target.closest(c.actions.reportActionPopup);if(null===b){return}a.preventDefault();var d=JSON.parse(b.dataset.popupAction);window.openpopup(a,d.jsfunctionargs)});document.addEventListener("click",function(a){var b=a.target.closest(c.actions.toggleCardView);if(b){var d=b.closest("tr"),e=b.querySelector("i");a.preventDefault();if(b.classList.contains(j.COLLAPSED)){d.classList.add(j.EXPANDED);e.classList.replace(j.ICONDOWN,j.ICONUP);b.classList.remove(j.COLLAPSED);b.setAttribute("aria-expanded","true")}else{d.classList.remove(j.EXPANDED);e.classList.replace(j.ICONUP,j.ICONDOWN);b.classList.add(j.COLLAPSED);b.removeAttribute("aria-expanded")}}});k=!0};a.init=l});
|
||||
function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core_reportbuilder/report",["exports","core/notification","core_reportbuilder/local/events","core_reportbuilder/local/selectors","core_table/dynamic","core_table/local/dynamic/selectors"],function(a,b,c,d,e,f){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);c=h(c);d=h(d);f=h(f);function g(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;g=function(){return a};return a}function h(a){if(a&&a.__esModule){return a}if(null===a||"object"!==_typeof(a)&&"function"!=typeof a){return{default:a}}var b=g();if(b&&b.has(a)){return b.get(a)}var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a){if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;if(f&&(f.get||f.set)){Object.defineProperty(c,e,f)}else{c[e]=a[e]}}}c.default=a;if(b){b.set(a,c)}return c}function i(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function j(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){i(h,d,e,f,g,"next",a)}function g(a){i(h,d,e,f,g,"throw",a)}f(void 0)})}}var k={COLLAPSED:"collapsed",EXPANDED:"show",ICONUP:"fa-angle-up",ICONDOWN:"fa-angle-down"},l=!1,m=function(){if(l){return}document.addEventListener(c.tableReload,function(){var a=j(regeneratorRuntime.mark(function a(c){var g,h,i,j;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:h=c.target.closest(d.regions.report);if(!(null===h)){a.next=3;break}return a.abrupt("return");case 3:i=h.querySelector(f.main.region);j=(null===(g=c.detail)||void 0===g?void 0:g.preservePagination)?null:1;a.next=7;return(0,e.setPageNumber)(i,j,!1).then(e.refreshTableContent).catch(b.default.exception);case 7:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}());document.addEventListener("click",function(a){var b=a.target.closest(d.actions.reportActionPopup);if(null===b){return}a.preventDefault();var c=JSON.parse(b.dataset.popupAction);window.openpopup(a,c.jsfunctionargs)});document.addEventListener("click",function(a){var b=a.target.closest(d.actions.toggleCardView);if(b){var c=b.closest("tr"),e=b.querySelector("i");a.preventDefault();if(b.classList.contains(k.COLLAPSED)){c.classList.add(k.EXPANDED);e.classList.replace(k.ICONDOWN,k.ICONUP);b.classList.remove(k.COLLAPSED);b.setAttribute("aria-expanded","true")}else{c.classList.remove(k.EXPANDED);e.classList.replace(k.ICONUP,k.ICONDOWN);b.classList.add(k.COLLAPSED);b.removeAttribute("aria-expanded")}}});l=!0};a.init=m});
|
||||
//# sourceMappingURL=report.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -21,6 +21,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
import Notification from 'core/notification';
|
||||
import * as reportEvents from 'core_reportbuilder/local/events';
|
||||
import * as reportSelectors from 'core_reportbuilder/local/selectors';
|
||||
import {setPageNumber, refreshTableContent} from 'core_table/dynamic';
|
||||
@@ -58,7 +59,8 @@ export const init = () => {
|
||||
const pageNumber = event.detail?.preservePagination ? null : 1;
|
||||
|
||||
await setPageNumber(tableRoot, pageNumber, false)
|
||||
.then(refreshTableContent);
|
||||
.then(refreshTableContent)
|
||||
.catch(Notification.exception);
|
||||
});
|
||||
|
||||
// Listen for trigger popup events.
|
||||
|
||||
@@ -132,11 +132,19 @@ class groupconcat extends base {
|
||||
|
||||
// Store original names of all values that would be present without aggregation.
|
||||
$valuenames = array_keys($values);
|
||||
$values = explode(self::FIELD_VALUE_DELIMETER, (string) reset($values));
|
||||
$valuenamescount = count($valuenames);
|
||||
|
||||
// Loop over each extracted value from the concatenated string.
|
||||
$values = explode(self::FIELD_VALUE_DELIMETER, (string) reset($values));
|
||||
foreach ($values as $value) {
|
||||
$originalvalue = array_combine($valuenames, explode(self::COLUMN_FIELD_DELIMETER, $value));
|
||||
|
||||
// Ensure we have equal number of value names/data, account for truncation by DB.
|
||||
$valuedata = explode(self::COLUMN_FIELD_DELIMETER, $value);
|
||||
if ($valuenamescount !== count($valuedata)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$originalvalue = array_combine($valuenames, $valuedata);
|
||||
$originalfirstvalue = reset($originalvalue);
|
||||
|
||||
// Once we've re-constructed each value, we can apply callbacks to it.
|
||||
|
||||
Reference in New Issue
Block a user