Separate Type Contructors for (var)char and n(var)char
維護者通常 2 天內回覆
@gargsaumya 已經在處理了。
開始於 2025年8月15日。
評估
這個 Issue 還沒有評估資料。
描述
Is your feature request related to a problem? Please describe.
Python strings don't have 2 distinct data types like SQL Server (which has (var)char and n(var)char); you define a string with single quotes (') or double quote (") and they have the same inferred data type. This poses a problem with SQL Server parameters as the "safer" option is to assume the string is an nvarchar, however, this causes problems with SARGability as if the column the parameter is compared to is varchar, at the column must be implicitly converted and thus can result in (significant) performance issues due to indexes not being about to be used for seek operations.
For those using UTF-8 collations, this could be even more of a "gotcha", as UTF-8 and UTF-16 will support the same characters (unlike Windows-1252, for example, which only supports 1 byte characters), but varchar values would be UTF-8 while nvarchar UTF-16. Many users are likely writing their Python files in UTF-8 so the strings they see are also UTF-8; if they are using a UTF-8 collated database then one would assume they would want varchar parameters, not nvarchar, as it's unlikely they would be using any nvarchar columns.
Describe the solution you'd like
Provide type objects and constructors for both varchar and nvarchar datatypes. This might copy types found else where, such as the String and WString ("Wide String") objects/constructors.
Describe alternatives you've considered
The alternative is that developers would need to be explicit and CAST/CONVERT the value to a varchar in the appropriate clause(s); i.e. MyColumn = CONVERT(varchar(30), ?). Otherwise they could assign the parameter to a variable first: DECLARE @MyColumn varchar(30) = ?;. This, however, might look odd if the query has to be ported to a different language that doesn't use inferred data types, and is likely to be less obvious to do to the "inexperience" developer.
- 主要語言
- Python
- 星號
- 478
- 分支
- 62
- 平均合併
- 3 天 1 小時
- 30 天內合併 PR
- 26
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/mssql-python 的其他 Issue
-
area: bulk-copy triage needed
難度 2/5 1-3 小時 新手友好度 70/100
microsoft/mssql-python#843 · 1 則留言 ·
維護者通常 2 天內回覆
-
triage needed
難度 5/5 一週以上 新手友好度 38/100
microsoft/mssql-python#850 · 1 則留言 ·
維護者通常 2 天內回覆
-
triage needed
難度 4/5 3-5 天 新手友好度 22/100
microsoft/mssql-python#849 · 1 則留言 ·
維護者通常 2 天內回覆
-
triage needed
難度 4/5 3-5 天 新手友好度 20/100
microsoft/mssql-python#848 · 1 則留言 ·
維護者通常 2 天內回覆
-
triage needed
難度 4/5 3-5 天 新手友好度 35/100
microsoft/mssql-python#846 · 1 則留言 ·
維護者通常 2 天內回覆
查看 microsoft/mssql-python 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
sierra-research/tau2-bench#635 ·
維護者通常 1 天內回覆
-
The add-ssm-model skill requires a Cython simulator; the contributing guide allows Python ones可能已有人在做 @fmuia 今天認領。 未關閉documentation skill
難度 2/5 1-3 小時 新手友好度 83/100
lnccbrown/ssm-simulators#406 ·
維護者通常 4 天內回覆
-
難度 1/5 1 小時以內 新手友好度 95/100
btclib-org/btclib-ecc#309 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 68/100
jbacalso24/mimry#459 · 1 則留言 ·
維護者通常 1 天內回覆
-
auth bug high-priority
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆