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 天 19 分钟
- 30 天内合并 PR
- 28
环境准备
在浏览器里用你自己的 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
难度 4/5 3-5 天 新手友好度 35/100
microsoft/mssql-python#846 · 1 条评论 ·
维护者通常 2 天内回复
-
macOS: encrypted connections fail after Homebrew moved the `openssl` alias to `openssl@4`可能已有人在做 @bewithgaurav 于 14 天前认领。 未关闭area: packaging-platform bug triage needed
难度 4/5 3-5 天 新手友好度 55/100
microsoft/mssql-python#826 · 2 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
Announcement: mssql-python is coming to Django through mssql-django 2.0可能重新可做 @bewithgaurav 于 41 天前认领,目前没有进行中的 PR。 未关闭announcement
microsoft/mssql-python#748 · 已指派 1 人 ·
维护者通常 2 天内回复
-
Connection pool can briefly exceed max_size when pooling is disabled under load可能已有人在做 @bewithgaurav 于 24 天前认领。 未关闭area: connectivity-auth bug triage done under development
难度 4/5 3-5 天 新手友好度 62/100
microsoft/mssql-python#746 · 1 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
查看 microsoft/mssql-python 的全部 Issue
相似的 Issue
-
good first issue
难度 2/5 1-3 小时 新手友好度 85/100
btclib-org/btclib-node#1955 ·
维护者通常 1 天内回复
-
documentation v0.9.2
难度 2/5 半天 新手友好度 72/100
khuisman/mcp-gee-sweet#1033 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
ossf/cve-bin-tool#5966 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 2 天内回复
-
write_iceberg ignores the table's write.parquet.compression-codec property可能已有人在做 @YuangGao 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
Eventual-Inc/Daft#7606 ·
维护者通常 1 天内回复