Skip to content
Snippets Groups Projects
Commit 8f508853 authored by colemanw's avatar colemanw
Browse files

APIv4 - Increase alias max length to 256

parent 445e4ab2
Branches
Tags
No related merge requests found
......@@ -534,7 +534,7 @@ class Api4SelectQuery {
// Which might contain an alias. Split on the keyword "AS"
list($entity, $alias) = array_pad(explode(' AS ', $entity), 2, NULL);
// Ensure alias is a safe string, and supply default if not given
$alias = $alias ? \CRM_Utils_String::munge($alias) : strtolower($entity);
$alias = $alias ? \CRM_Utils_String::munge($alias, '_', 256) : strtolower($entity);
// First item in the array is a boolean indicating if the join is required (aka INNER or LEFT).
// The rest are join conditions.
$side = array_shift($join) ? 'INNER' : 'LEFT';
......
......@@ -73,7 +73,7 @@ abstract class SqlExpression {
public static function convert(string $expression, $parseAlias = FALSE, $mustBe = [], $cantBe = ['SqlWild']) {
$as = $parseAlias ? strrpos($expression, ' AS ') : FALSE;
$expr = $as ? substr($expression, 0, $as) : $expression;
$alias = $as ? \CRM_Utils_String::munge(substr($expression, $as + 4)) : NULL;
$alias = $as ? \CRM_Utils_String::munge(substr($expression, $as + 4), '_', 256) : NULL;
$bracketPos = strpos($expr, '(');
$firstChar = substr($expr, 0, 1);
$lastChar = substr($expr, -1);
......@@ -153,7 +153,7 @@ abstract class SqlExpression {
* @return string
*/
public function getAlias(): string {
return $this->alias ?? $this->fields[0] ?? \CRM_Utils_String::munge($this->expr);
return $this->alias ?? $this->fields[0] ?? \CRM_Utils_String::munge($this->expr, '_', 256);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment