SQL system data type synonym name lost and replaced during parsing

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

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

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
sql
Lĩnh vực
compilers

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện các ví dụ NATIONAL CHARACTER VARYING và DOUBLE PRECISION, rồi kiểm tra DatatypeReference.Name.BaseName cùng với SqlDataTypeOption. Xác định nơi quá trình phân tích thay thế hoặc loại bỏ từ đồng nghĩa được cung cấp; công việc hoàn tất khi AST giữ nguyên từng tên kiểu dữ liệu ban đầu đồng thời vẫn giữ lại thông tin kiểu đã được parser chuẩn hóa.

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

Mô tả

ScriptDom version: 161.9142.1
Compatibility level: 150

While trying to implement custom TSQL linter rule which should prevent developers from using non-conventional data type names (synonyms) I've faced an issue: ScriptDom modifies type name during parsing. Which makes detection of synonym usage impossible or hard to implement.

For example:

DECLARE
    @a NATIONAL CHARACTER VARYING (100)
    , @b DOUBLE PRECISION
    , @c INTEGER

Here only "INTEGER" synonym (for INT data type) can be easily detected. Data type name for @a is delivered to DatatypeReference.Name.BaseName partially: it contains CHARACTER word only. Yes, "character" is a synonym as well, but not the one that was actually provided.

Moreover, DOUBLE PRECISION gets lost totally: DatatypeReference.Name.BaseName.Value here comes as Float. It's good to know that the parser knows what is what but actual script contents disappeared after parsing - IMHO this is no good.

I'd expect ScriptDom parser to keep what was provided - a full original data type name no matter if it was a UDT or registered sql-server supplied type synonym. As far as I can understand ScriptDom has SqlDataTypeOption for internal needs and this DatatypeReference's property does contain NVarChar and Float as expected for both of mentioned examples above. Seems like BaseName could keep the original type name.

Ngôn ngữ chính
GAP
Star
277
Fork
43
Merge trung bình
6 ngày 17 giờ
Pull request đã merge (30 ngày)
3

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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 microsoft/SqlScriptDOM

Tất cả issue của microsoft/SqlScriptDOM

Issue tương tự

Thêm issue về Compilers

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.