Skip to content

feat: optional driver-owned table query templates - #818

Merged
debba merged 3 commits into
mainfrom
feat/optional-table-query-templates
Sep 29, 2026
Merged

debba merged 3 commits into
mainfrom
feat/optional-table-query-templates

Conversation

@debba

@debba debba commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add optional capabilities.table_query_templates and get_table_query_template for SELECT/UPDATE/DELETE previews.
  • Delegate Generate SQL to the connection driver only when opted in; retain existing SQL generation for built-in drivers and older plugins.
  • Keep CREATE TABLE inspection and all existing RPC signatures unchanged.
  • Forward structured identifiers, schema, columns and the explicit SELECT limit to the plugin.
  • Guard the modal against stale responses and show real errors instead of silently generating a different SQL dialect.

Backward compatibility

  • Capability defaults to false and is omitted when serialized as false.
  • The DatabaseDriver trait has a default implementation; existing drivers need no RPC implementation.
  • Only a remote JSON-RPC -32601 selects the legacy fallback; transport errors, other error codes and malformed results propagate.
  • Old hosts ignore the new plugin capability; no plugin minimum runtime increase is required solely for this optional feature.

Validation

  • 105 frontend tests passed (SQL generation, optional templates, target modals and Command Palette).
  • 136 Rust plugin-area tests and 2 driver-trait tests passed.
  • TypeScript project build/typecheck and ESLint on changed source passed.
  • GitNexus staged change analysis: 16 files, medium risk; changes limited to opt-in templates and command registration.

Coordination

Refs TabularisDB/tabularis-sqlserver-plugin#26.
Plugin pagination fix: TabularisDB/tabularis-sqlserver-plugin#30.
The matching plugin implementation is on feat/table-query-templates; this draft freezes the additive contract for joint review.

Tabularium

Before publishing the plugin, register the optional boolean table_query_templates (default false) under the driver-kind capabilities schema. Ingestion uses lenient AJV validation with removeAdditional: all, which otherwise strips the flag. No database migration, endpoint or SDK change is needed. Registry production configuration has not been modified.

@debba

debba commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator Author

Matching SQL Server implementation: TabularisDB/tabularis-sqlserver-plugin#31 (stacked on the pagination fix in #30 of that repository). The new flag must be registered in the Tabularium driver-kind schema before publishing the plugin; registry code and production configuration remain untouched.

@debba
debba marked this pull request as ready for review September 29, 2026 07:47
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Preview build

The preview build of commit a54684c failed (skipped). See the workflow run for logs.

Comment thread plugins/PLUGIN_GUIDE.md
| `connection_string` | bool | Set `false` to hide the connection string import UI for this driver. Defaults to `true` for network drivers. `file_based` and `folder_based` drivers skip the import UI automatically regardless of this flag. |
| `connection_string_example` | string | Optional placeholder example shown in the connection string import field (e.g. `"clickhouse://user:pass@localhost:9000/db"`). Also accepted as camelCase `connectionStringExample`. |
| `identifier_quote` | string | Character used to quote SQL identifiers. Use `"\""` for ANSI standard or `` "`" `` for MySQL style. |
| `table_query_templates` | bool | Opts the Generate SQL dialog into the optional `get_table_query_template` RPC for SELECT/UPDATE/DELETE previews. Defaults to `false`; older plugins and built-in drivers keep the existing host templates. See [Table Query Templates](#table-query-templates). |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: New capability is missing from plugins/manifest.schema.json

plugins/manifest.schema.json declares capabilities with "additionalProperties": false and lists every other capability (inline_pk, manage_tables, materialized_views, …) under capabilities.properties. This PR documents table_query_templates in the guide but does not add it to that schema, so any manifest that sets the flag is rejected by the schema the guide itself points plugin authors to (plugins/manifest.schema.json, linked from PLUGIN_GUIDE.md and from the create-plugin template README). The Tabularium-side rollout mentioned below does not cover this in-repo artifact.

Add a "table_query_templates": { "type": "boolean", "default": false, ... } entry to capabilities.properties so the documented flag validates.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in a54684c: both plugins/manifest.schema.json and plugins/tabularium-extensions.schema.json now declare the optional, default-false property. Added two schema regression tests in tests/utils/tableQueryTemplateSchema.test.ts.

Comment thread plugins/PLUGIN_GUIDE.md
are unchanged. This is not a replacement for the existing DDL methods.
- Older hosts ignore the new manifest capability and never call the method.
Plugins need not raise `min_runtime_version` solely for this optional feature.
- The capability is a static manifest opt-in, not a connection-metadata override.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SUGGESTION: A plugin echoing this capability in get_connection_metadata will fail the whole metadata parse

ConnectionCapabilityOverrides (src-tauri/src/plugins/connection_metadata.rs:35) is #[serde(deny_unknown_fields)] and its apply! list does not include table_query_templates. A plugin that returns its full capability set from get_connection_metadata — which this guide now makes easy to do, since the field is documented as a capability — will make deserialization fail with an unknown-field error, failing the entire connection metadata load rather than just ignoring the key.

Consider either accepting (and ignoring) table_query_templates in the overrides struct, or noting in the guide that plugins must not return the key from get_connection_metadata.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is intentionally a static manifest opt-in. The get_table_query_template compatibility section already states: "The capability is a static manifest opt-in, not a connection-metadata override." Plugins must not echo the full static capability set through the restricted get_connection_metadata override object. Connection snapshots inherit table_query_templates from the installed manifest, so keeping the existing deny_unknown_fields allowlist is deliberate.

@kilo-code-bot

kilo-code-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The two findings from the previous review are resolved by the latest commits: table_query_templates is now declared in both plugins/manifest.schema.json (line 166, inside the additionalProperties: false capabilities object, not in required) and plugins/tabularium-extensions.schema.json (line 118), with a schema contract test in tests/utils/tableQueryTemplateSchema.test.ts. The ConnectionCapabilityOverrides concern is addressed in the guide itself, which now states at plugins/PLUGIN_GUIDE.md:1352 that the capability is a static manifest opt-in and not a connection-metadata override.

Files Reviewed (5 files)
  • plugins/manifest.schema.json
  • plugins/tabularium-extensions.schema.json
  • tests/utils/tableQueryTemplateSchema.test.ts
  • src-tauri/tests/postgres_integration/parity.rs
  • plugins/PLUGIN_GUIDE.md
Assumptions & Not Verified
  • Read-only review: no build, lint, typecheck, or test run was executed.
  • The Tabularium-side registry registration described in the PR description lives in another repository and was not reviewed.
  • The two earlier inline comments remain in the thread; this run posted no new inline comments.
Previous Review Summary (commit 288c20a)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 288c20a)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
plugins/PLUGIN_GUIDE.md 130 New table_query_templates capability is absent from plugins/manifest.schema.json, whose capabilities object uses additionalProperties: false, so a manifest using the flag is rejected by the schema the guide points authors to.

SUGGESTION

File Line Issue
plugins/PLUGIN_GUIDE.md 1352 ConnectionCapabilityOverrides is deny_unknown_fields and omits table_query_templates; a plugin returning the key from get_connection_metadata fails the whole metadata parse.
Files Reviewed (16 files)
  • plugins/PLUGIN_GUIDE.md - 2 issues
  • src-tauri/src/commands.rs - 0 issues
  • src-tauri/src/drivers/driver_trait.rs - 0 issues
  • src-tauri/src/drivers/mysql/mod.rs - 0 issues
  • src-tauri/src/drivers/postgres/mod.rs - 0 issues
  • src-tauri/src/drivers/sqlite/mod.rs - 0 issues
  • src-tauri/src/lib.rs - 0 issues
  • src-tauri/src/models.rs - 0 issues
  • src-tauri/src/models/table_query_template.rs - 0 issues
  • src-tauri/src/plugins/driver.rs - 0 issues
  • src-tauri/src/plugins/table_query_template_tests.rs - 0 issues
  • src-tauri/tests/postgres_integration/parity.rs - 0 issues
  • src/components/modals/GenerateSQLModal.tsx - 0 issues
  • src/types/plugins.ts - 0 issues
  • src/utils/tableQueryTemplates.ts - 0 issues
  • tests/components/modals/GenerateSQLTemplates.test.tsx - 0 issues
  • tests/utils/tableQueryTemplates.test.ts - 0 issues
Assumptions & Not Verified
  • Read-only review: no build, lint, typecheck, or test run was executed.
  • The Tabularium-side capability registration mentioned in the PR description lives in a separate repository and was not reviewed.

Reviewed by free · Input: 0 · Output: 0 · Cached: 0

@debba
debba merged commit b5f81cc into main Sep 29, 2026
9 checks passed
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.

1 participant