SQL Parameter Detection and Substitution in Plan Editor

Đang mở
#20,377 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
sql, typescript
Lĩnh vực
database, frontend

Hướng nghiên cứu

Bắt đầu bằng cách đọc sqlParamDetector.ts, SqlParamPanel.vue và patch của EditorView.vue, sau đó lần theo luồng tải SQL lên của trình chỉnh sửa Plan. Xác nhận cách phát hiện sáu mẫu tham số được liệt kê, cách gửi các giá trị và cách tạo chuỗi EXEC của stored procedure; hoàn thành khi biểu mẫu inline xử lý được các trường hợp đó mà không yêu cầu chỉnh sửa SQL trực tiếp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
TypeScript
Star
14.7k
Fork
1k
Merge trung bình
7 giờ 23 phút
Pull request đã merge (30 ngày)
454

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của bytebase/bytebase

Tất cả issue của bytebase/bytebase

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.