Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] Sybase ASE: Encoding issue (works in msnodesqlv8, fails in node-odbc with \x1A artifacts)

未关闭
#452 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
领域
backend, databases

调研方向

从 node-odbc 查询路径及其 ODBC 列绑定和字符转换处理入手;该 issue 未指定源文件或测试。使用 Adaptive Server Enterprise 或 FreeTDS 驱动程序重现 Sybase ASE 案例,将结果与 msnodesqlv8 进行比较,并在非 ASCII 字符串不再包含 \x1A 残留时认为该 issue 已完成。

由索引模型根据 Issue 内容生成。

描述

Description:

I am using node-odbc to connect to a Sybase ASE database. I am encountering an issue where string data containing special characters or specific encodings is returned with substitute characters (\x1A) or corrupted text.

I have verified that the exact same query and database setup works correctly using msnodesqlv8 package. Since msnodesqlv8 retrieves the correct Unicode/string data within the same Node.js environment, this suggests the issue is specific to how node-odbc is binding the columns (likely defaulting to SQL_C_CHAR when it needs SQL_C_WCHAR or vice versa) or handling the charset conversion from the ODBC driver.

Environment:

OS: Windows 10

ODBC Driver: Adaptive Server Enterprise / FreeTDS

Database: Sybase ASE

Reproduction Steps:

Connect to Sybase ASE using node-odbc.

Select data from a column containing non-ASCII characters.

Observe artifacts (\x1A) in the output.

Run the same query using msnodesqlv8 and observe correct output.

Comparison Code:

const odbc = require('node-odbc');
const sql = require('msnodesqlv8');

const query = "SELECT test_column FROM MyTable WHERE id = 1";

// 1. Test with msnodesqlv8 (Works)
const connectionStringMS = "Driver={...};Server=..."; // Your working connection string
sql.query(connectionStringMS, query, (err, rows) => {
    if (err) console.error(err);
    console.log('msnodesqlv8 result:', rows); 
    // Output: Correct String (e.g., "München")
});

// 2. Test with node-odbc (Fails)
async function runOdbc() {
    const connection = await odbc.connect('DSN=MySybaseDSN;UID=...;PWD=...');
    const result = await connection.query(query);
    console.log('node-odbc result:', result);
    // Output: Corrupted String (e.g., "München" becomes "M\x1A - \x1A")
}

runOdbc();

Expected Behavior:

node-odbc should return the string correctly, matching the behavior of msnodesqlv8.

Actual Behavior:

node-odbc returns data containing \x1A (SUB) characters. This implies a mismatch in the column binding type (ODBC C-Type) requested by node-odbc versus what the driver provides.

Possible Cause:

It appears node-odbc is not correctly inferring the need for Wide Character binding (SQL_C_WCHAR) for this driver, whereas msnodesqlv8 (via OLE DB) handles the buffer width correctly.

主要语言
JavaScript
星标
159
派生
92
平均合并
5 小时 59 分钟
30 天内合并 PR
3

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

IBM/node-odbc 的其他 Issue

查看 IBM/node-odbc 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。