-
Notifications
You must be signed in to change notification settings - Fork 27
v1.6.26 #172
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
Merged
Merged
v1.6.26 #172
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
roncodes
commented
Nov 20, 2025
- feat: ability to add options via array for computed columns
- Fixed bug where computed columns (e.g., hire_days_current_month) in aggregate functions (SUM, AVG, etc.) caused SQL errors - Backend now properly expands computed column expressions when used in aggregates - Enables reports to aggregate computed columns without errors - Resolves 'Unknown column' errors for computed columns in GROUP BY queries Example: Before: SUM(table.computed_column) -> Error After: SUM(GREATEST(0, DATEDIFF(...))) -> Success
Fix: Support computed columns in aggregate functions
- Added extractComputedColumnsFromAggregates() method to automatically extract computed columns from aggregateBy objects - Fixes issue where frontend sends computed column metadata in groupBy array but not in computed_columns array - Now properly populates computed_columns array from aggregateBy.computed and aggregateBy.computation fields - Enables the previous computed column aggregate fix to work correctly This completes the fix for computed column aggregation by handling the frontend's data structure.
Fix: Complete support for computed columns in aggregates
- Added 70+ additional SQL functions to allowedFunctions list - Organized functions by category (Date/Time, String, Numeric, Conditional, etc.) - Added LAST_DAY function (fixes computed column validation error) - Added comprehensive date functions: DAYOFWEEK, DAYOFMONTH, QUARTER, TIMESTAMPDIFF, etc. - Added string functions: CONCAT_WS, LEFT, RIGHT, LPAD, RPAD, LOCATE, etc. - Added numeric/math functions: CEIL, FLOOR, SQRT, POW, trigonometric functions, etc. - Added conditional functions: IF - Added aggregate functions: COUNT, SUM, AVG, MIN, MAX, GROUP_CONCAT - Added type conversion: CAST, CONVERT - All functions are safe, read-only MySQL functions - Enables more powerful and flexible computed columns in reporting This allows users to create sophisticated computed columns for complex reporting scenarios.
Add comprehensive SQL function support to ComputedColumnValidator
- Updated ComputedColumnValidator.validate() to accept array of computed columns - Updated validateColumnReferences() to check if a reference is to another computed column - Updated ReportQueryConverter to pass computed_columns array to validator - Enables computed columns to build on top of each other (e.g., monthly_hire_revenue_current can reference hire_days_current_month) - Fixes validation error: "Column reference 'hire_days_current_month' does not exist" This allows for more modular and reusable computed column definitions.
…ted column expansion - Added comprehensive SQL function keywords list (70+ functions) to prevent incorrect aliasing - Added computed column reference expansion (e.g., hire_days_current_month expands to its expression) - Prevents functions like LAST_DAY, DATE_FORMAT from being prefixed with table aliases - Recursively expands nested computed column references up to 10 levels deep - Fixes SQL syntax errors: "fliit_asset_allocations.LAST_DAY(CURDATE())" now correctly becomes "LAST_DAY(CURDATE())" - Fixes computed column references: "hire_days_current_month" now expands to its full expression This resolves the MySQL syntax error when using computed columns in aggregates.
- Protect string literals FIRST before any other processing - Then expand computed column references - Then resolve column references to table aliases - This prevents SQL functions in expanded expressions from being incorrectly prefixed with table aliases - Fixes: fliit_asset_allocations.GREATEST(...) → GREATEST(...) - Fixes: fliit_asset_allocations.LEAST(...) → LEAST(...)
- Changed order: expand computed columns FIRST, then protect string literals - This ensures string literals in expanded expressions are properly protected - Fixes: '%Y-%m-01' being corrupted to '%fliit_asset_allocations.Y-%fliit_asset_allocations.m-01' - String literals from expanded computed columns are now correctly protected - Prevents column resolution inside string literals
- Added Step 3: Protect SQL function calls (function_name followed by '(')
- Replaces function calls with placeholders before column resolution
- Restores function calls after column resolution
- Fixes: fliit_asset_allocations.GREATEST(...) → GREATEST(...)
- Fixes: fliit_asset_allocations.LEAST(...) → LEAST(...)
- Fixes: fliit_asset_allocations.DATEDIFF(...) → DATEDIFF(...)
- Simplified keywords list to only non-function keywords
- All SQL functions now properly protected
- Updated resolveAliasAndColumn to handle deep nested paths - Now resolves paths step-by-step (e.g., asset -> asset.financials) - Fixes: asset.financials.monthly_hire_revenue now resolves correctly - Uses the deepest resolved table alias as the base - Handles cases where only part of the path has been joined - Example: asset.financials.monthly_hire_revenue → fliit_asset_allocations_asset_financials.monthly_hire_revenue
- Created createJoinsForComputedColumn() method to parse computed column expressions - Extracts relationship paths (e.g., asset.financials) from column references - Automatically creates auto-joins for detected relationship paths - Handles recursive computed column expansion - Fixes 'Unknown column' errors when computed columns reference nested relationships
- Removed early break in path resolution loop - Now correctly resolves asset.financials.monthly_hire_revenue to the financials table alias - Previously was breaking after finding 'asset' and returning the asset table alias - Now continues through all segments and uses the longest matching path - Fixes 'Unknown column' error when computed columns reference nested relationships in aggregates
- Moved join creation for computed columns to processAutoJoins phase - Added collectAutoJoinPathsFromComputedColumns() method - Extracted extractRelationshipPathsFromExpression() as reusable method - Joins are now created BEFORE aggregate expressions are resolved - Fixes 'Unknown column' error when aggregating computed columns with nested relationships - Previously: joins created during buildComputedColumns (too late for aggregates) - Now: joins created during processAutoJoins (before buildSelectClause)
- Removed buildComputedColumns() call in grouped mode - Computed columns in grouped queries now only appear when used in aggregates - Prevents non-aggregated computed columns from violating GROUP BY rules - Computed columns are still properly resolved when used in aggregate expressions - Fixes: Expression not in GROUP BY clause error with computed columns
- Generalized examples in comments from specific use cases to generic relationship patterns - Changed 'asset.financials.monthly_hire_revenue' to 'relationship.nested.column' - Removed specific table alias examples - Maintains separation between core framework and commercial modules - No functional changes, only documentation/comment updates
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.