diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2019-05-16 05:58:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-16 05:58:44 +0300 |
commit | ed823e9c1521a6a5aada6fc1572433845322967f (patch) | |
tree | 3c273d4e972206930661b22312c4ca7175fc2dda /core | |
parent | 05017ba88ec611f63bf223728990351212ff560f (diff) |
Ignore variables that start w/ @ when auto-detecting tables in segment sql expressions. (#14425)
* Ignore variables that start w/ @ when auto-detecting tables in segment sql expressions.
* Add test & fix
* Make sure column detection excludes decimal numbers.
Diffstat (limited to 'core')
-rw-r--r-- | core/Segment/SegmentExpression.php | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/core/Segment/SegmentExpression.php b/core/Segment/SegmentExpression.php index 997d7e7b5f..ae4225006f 100644 --- a/core/Segment/SegmentExpression.php +++ b/core/Segment/SegmentExpression.php @@ -315,8 +315,11 @@ class SegmentExpression */ public static function parseColumnsFromSqlExpr($field) { - preg_match_all('/\b`?([a-zA-Z0-9_]+`?\.`?[a-zA-Z0-9_`]+)`?\b/', $field, $matches); + preg_match_all('/[^@a-zA-Z0-9_]?`?([@a-zA-Z_][@a-zA-Z0-9_]*`?\.`?[a-zA-Z0-9_`]+)`?\b/', $field, $matches); $result = isset($matches[1]) ? $matches[1] : []; + $result = array_filter($result, function ($value) { // remove uses of session vars + return strpos($value, '@') === false; + }); $result = array_map(function ($item) { return str_replace('`', '', $item); }, $result); |