Skip to content

Add granular query operation capabilities to driver schema#49

Merged
hotlong merged 8 commits intomainfrom
copilot/document-driver-capabilities
Jan 21, 2026
Merged

Add granular query operation capabilities to driver schema#49
hotlong merged 8 commits intomainfrom
copilot/document-driver-capabilities

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 21, 2026

Drivers currently can only declare high-level capabilities (transactions, joins, full-text search). No mechanism exists to specify support for individual query operations, preventing ObjectQL from determining whether to push operations to the driver or compute in-memory.

Changes

Schema Enhancements

  • Added 6 query capability flags to DriverCapabilitiesSchema and DatasourceCapabilities:
    • queryFilters - WHERE clause support
    • queryAggregations - GROUP BY/aggregation functions
    • querySorting - ORDER BY support
    • queryPagination - LIMIT/OFFSET support
    • queryWindowFunctions - Window functions with OVER clause
    • querySubqueries - Nested SELECT support

Test Coverage

  • Updated all driver test fixtures with new capability flags
  • Added memory driver example demonstrating limited query support
  • Added realistic capability matrices for PostgreSQL, MongoDB, Salesforce, and Redis

Generated Artifacts

  • Updated JSON schemas and documentation

Example

// Memory driver - compute all operations in-memory
const memoryDriver: DriverInterface = {
  supports: {
    queryFilters: false,
    queryAggregations: false,
    querySorting: false,
    queryPagination: false,
    queryWindowFunctions: false,
    querySubqueries: false,
    // ...
  }
};

// PostgreSQL - push all operations to database
const postgresDriver: DriverInterface = {
  supports: {
    queryFilters: true,
    queryAggregations: true,
    querySorting: true,
    queryPagination: true,
    queryWindowFunctions: true,
    querySubqueries: true,
    // ...
  }
};

ObjectQL can now inspect these flags to determine whether to push query operations to the driver or handle them in-memory.

Original prompt

如何约定driver已经实现的能力比如目前的内存驱动实际上不支持查询条件


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 21, 2026

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

Project Deployment Review Updated (UTC)
spec Error Error Jan 21, 2026 4:29am

Request Review

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Document driver capabilities regarding current limitations Add granular query operation capabilities to driver schema Jan 21, 2026
Copilot AI requested a review from hotlong January 21, 2026 02:51
@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 21, 2026

@copilot 目前实现已经非常完整,我只有一个小的建议供参考:

• 默认值考虑:目前所有新标志的默认值似乎都是 false(在 JSON Schema 中显式设为 false,Zod 中虽未显式但在测试中体现了这一点)。这是一个安全的默认策略(“悲观策略”),确保了如果驱动没声明支持,引擎会兜底处理。这很好。

@hotlong hotlong marked this pull request as ready for review January 21, 2026 04:20
Copilot AI review requested due to automatic review settings January 21, 2026 04:20
@github-actions github-actions bot added documentation Improvements or additions to documentation protocol:system tests size/m labels Jan 21, 2026
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 pull request adds granular query operation capabilities to the driver schema, enabling ObjectQL to determine which query operations can be pushed to the database driver versus computed in-memory. The PR introduces 6 new capability flags for common query operations (filters, aggregations, sorting, pagination, window functions, and subqueries).

Changes:

  • Added 6 new query capability boolean flags to DriverCapabilitiesSchema and DatasourceCapabilities schemas
  • Updated all test fixtures with realistic capability matrices for PostgreSQL, MongoDB, Salesforce, Redis, and a new memory driver example
  • Regenerated JSON schemas and documentation with new capability fields

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/spec/src/system/driver.zod.ts Added 6 query capability fields to DriverCapabilitiesSchema with comprehensive JSDoc documentation and .describe() calls
packages/spec/src/system/datasource.zod.ts Added 6 query capability fields to DatasourceCapabilities; removed aggregation field in favor of queryAggregations
packages/spec/src/system/driver.test.ts Updated all test fixtures with new capability flags; added realistic examples for PostgreSQL, MongoDB, Salesforce, Redis, and memory drivers
packages/spec/json-schema/DriverInterface.json Auto-generated JSON schema updated with new required capability fields
packages/spec/json-schema/DriverDefinition.json Auto-generated JSON schema updated with new capability fields and defaults
packages/spec/json-schema/DriverCapabilities.json Auto-generated JSON schema updated with new required capability fields
packages/spec/json-schema/DatasourceCapabilities.json Auto-generated JSON schema updated with new capability fields and defaults
packages/spec/json-schema/Datasource.json Auto-generated JSON schema updated with new capability fields
content/docs/references/system/integration/DatasourceCapabilities.mdx Auto-generated documentation updated with new capability fields (missing descriptions)
content/docs/references/system/DriverCapabilities.mdx Auto-generated documentation updated with new capability fields and descriptions

Comment on lines +65 to +81
/** Can execute WHERE clause filters natively? */
queryFilters: z.boolean().default(false),

/** Can perform aggregation (group by, sum, avg)? */
queryAggregations: z.boolean().default(false),

/** Can perform ORDER BY sorting? */
querySorting: z.boolean().default(false),

/** Can perform LIMIT/OFFSET pagination? */
queryPagination: z.boolean().default(false),

/** Can perform window functions? */
queryWindowFunctions: z.boolean().default(false),

/** Can perform subqueries? */
querySubqueries: z.boolean().default(false),
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The new query capability fields in DatasourceCapabilities lack .describe() method calls, which causes the auto-generated documentation to have empty descriptions. For consistency with DriverCapabilitiesSchema (which uses both JSDoc comments and .describe() calls) and to ensure proper documentation generation, each field should include a .describe() call with the description text.

For example:

  • queryFilters: z.boolean().default(false).describe('Can execute WHERE clause filters natively?')
  • queryAggregations: z.boolean().default(false).describe('Can perform aggregation (group by, sum, avg)?')

This would ensure the generated documentation tables include meaningful descriptions for each capability.

Copilot uses AI. Check for mistakes.

/** Can execute WHERE clause filters natively? */
queryFilters: z.boolean().default(false),

Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The removal of the aggregation capability field and its replacement with queryAggregations is a breaking change. While this rename provides better clarity and consistency with the new query capability naming scheme, any existing code that references capabilities.aggregation will break.

Consider:

  1. Adding a migration guide or deprecation notice in the PR description
  2. If backwards compatibility is required, temporarily supporting both field names with the old one marked as deprecated
  3. Documenting this breaking change in a CHANGELOG or migration guide
Suggested change
/**
* @deprecated Use `queryAggregations` instead.
* Legacy aggregation capability flag kept for backwards compatibility.
*/
aggregation: z.boolean().default(false).describe('Deprecated: use queryAggregations'),

Copilot uses AI. Check for mistakes.
Copilot AI and others added 3 commits January 21, 2026 04:26
Add missing query operation capabilities (queryFilters, queryAggregations,
querySorting, queryPagination, queryWindowFunctions, querySubqueries) to
match the updated DriverCapabilitiesSchema.

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Based on code review, updated capability flags to accurately reflect the
current implementation. Only queryPagination, jsonFields, and arrayFields
are actually supported.

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@hotlong hotlong merged commit 628fb75 into main Jan 21, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:system size/m tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants