Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

SQL Parameter Detection and Substitution in Plan Editor #20377

Copy link
Copy link

Description

@glaream-maker
Issue body actions

Is your feature request related to a problem?

Yes. We are currently evaluating Bytebase for adoption at our organization. In our workflow, vendor-provided SQL scripts are handed over to developers who are responsible for submitting them as database changes. However, these developers should not need to modify the SQL scripts directly. They should only be able to fill in the required parameter values and submit. Without a built-in parameter detection and substitution feature, developers are forced to manually edit the SQL files before uploading, which breaks our intended workflow and introduces risk.

Describe the solution you'd like

When a SQL file is uploaded in the Plan editor, Bytebase should automatically detect parameters in the script and display an inline form where the user can fill in the required values before the change is submitted. The detection should cover the following common patterns:

Stored Procedures — parameters defined in CREATE OR ALTER PROCEDURE signatures
SSMS Template Format — placeholders like <ParameterName,DATETIME,YYYY-MM-DD>, which is the standard template syntax used in SQL Server Management Studio (SSMS)
DECLARE with template values — DECLARE @StartDate DATETIME = '<StartDate,DATETIME,YYYY-MM-DD>'
Bare parameter usage — @param references with no DECLARE block
EXEC with parameters — EXEC SP_NAME @param1, @Param2

For stored procedures, the form should also generate a copyable EXEC string with the filled-in values.
We have already implemented a working proof of concept for this feature as a local customization in our Bytebase fork and are happy to contribute it as a pull request.

Additional context

We have implemented this as a proof of concept in our Bytebase fork. The implementation consists of three files:

sqlParamDetector.ts - a pure TypeScript utility that detects parameters across all 6 scenarios
SqlParamPanel.vue - a Vue component that renders the parameter input form inline in the editor
A small diff to EditorView.vue to trigger detection on SQL upload

The changes are self-contained and do not touch any core Bytebase functionality. We are happy to contribute this as a pull request if the team is interested.

sqlParamDetector.ts.txt

EditorView.patch

SqlParamPanel.vue.txt

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.