Skip to content

Fix SELECT * incorrectly included in aggregation-only queries#280

Merged
hotlong merged 2 commits intocopilot/implement-object-and-field-schemasfrom
copilot/update-action-steps-log
Jan 30, 2026
Merged

Fix SELECT * incorrectly included in aggregation-only queries#280
hotlong merged 2 commits intocopilot/implement-object-and-field-schemasfrom
copilot/update-action-steps-log

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 30, 2026

The QueryASTBuilder was generating invalid AST by including a wildcard field (SELECT *) in queries that specified only aggregations without explicit fields. This is semantically incorrect—aggregation queries should select only the aggregated values.

Changes

  • Modified buildSelect() to exclude the wildcard field when aggregations are present but no explicit fields are specified
  • Changed condition from else to else if (!query.aggregations || query.aggregations.length === 0)

Before/After

// Query with only aggregations
const query = {
  object: 'orders',
  aggregations: [
    { function: 'count', alias: 'total_count' },
    { function: 'sum', field: 'amount', alias: 'total_amount' }
  ]
};

// Before: ast.select.fields = [{ type: 'field', name: '*' }, ...2 aggregations] ❌
// After:  ast.select.fields = [...2 aggregations] ✅

This aligns the AST generation with standard SQL semantics where SELECT COUNT(*), SUM(amount) does not include an additional wildcard field.

Original prompt

引用: https://github.com/objectstack-ai/objectui/actions/runs/21512259815/job/61983227116#step:8:1


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Jan 30, 2026 10:46am
objectui-components Ready Ready Preview, Comment Jan 30, 2026 10:46am
objectui-crm-app Error Error Jan 30, 2026 10:46am

Request Review

… present

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Update action steps logging for better tracking Fix SELECT * incorrectly included in aggregation-only queries Jan 30, 2026
Copilot AI requested a review from hotlong January 30, 2026 10:42
@hotlong hotlong marked this pull request as ready for review January 30, 2026 11:29
Copilot AI review requested due to automatic review settings January 30, 2026 11:29
@hotlong hotlong merged commit 4dcbd1d into copilot/implement-object-and-field-schemas Jan 30, 2026
6 of 7 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the QueryASTBuilder where aggregation-only queries incorrectly included a wildcard field (SELECT *) in addition to the aggregation functions. The fix ensures that when a query specifies only aggregations without explicit fields, the generated AST contains only the aggregation fields, aligning with standard SQL semantics.

Changes:

  • Modified the buildSelect() method to conditionally add the wildcard field only when both fields and aggregations are absent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants