[BUG] null value bind to number value results in nulls for numeric values for subsequent calls even when afterwards a non null value is bound
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript, node.js
調査の方向性
提供された Node.js の再現コードを実行し、statement.bind と statement.execute の呼び出しから調査を始め、ループの各反復でパラメータがどのように再利用されるかに注目してください。2 行目で null をバインドした後も、3 行目に挿入された行がバインドされた数値 3 を保持していれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe your system
- odbc Package Version: 2.4.7
- ODBC Driver: Microsoft ODBC Driver V18
- Database Name: SQLServer
- Database Version: 2019
- Database OS: Windows
- Node.js Version: 16.15.1
- Node.js OS: Mac Ventura 13.3
Describe the bug
A prepared statement is created to insert values into a table with 3 parameters.
In a loop 3 rows will be inserted:
- For the first row all parameters will be bound to values.
- In the second row parameters 2 and 3 are bound to null values.
- in the third row parameters 2 and 3 are bound to values.
The bound value for the numeric value for row 3 is not inserted in the database. The column value is inserted as a null value.
It seems that after binding a null value to a numeric afterwards non null values are inserted as null values in the database.
Expected behavior
Proper insert of values after bind.
To Reproduce
Execute the provided script under code.
Code
const odbc = require('odbc');
run().then(
() => process.exit(),
error => {
console.log(error);
process.exit();
},
);
async function run() {
// connect to the database
const driver = 'MSSQL2019';
const server = 'localhost';
const uid = 'sa';
const password = 'iRefact2017';
const connectionString = `DSN=${driver};Uid=${uid};Pwd=${password};TrustServerCertificate=yes;`;
const connection = await odbc.connect(connectionString);
// initialize the connection
await connection.setIsolationLevel(odbc.SQL_TXN_READ_COMMITTED);
await connection.beginTransaction();
await connection.query('set nocount on');
// create a table to test the reuse of parameters
await connection.query('create table dbo.test_parameters (id int, textValue varchar(100), numValue int);');
// create a statement to insert values into the table using parameters
const statement = await connection.createStatement();
await statement.prepare('insert into dbo.test_parameters values (?, ?, ?);');
// insert 3 rows:
// row 1 with values for all parameters
// row 2 with null values for parameters 2 and 3
// row 3 with values for all parameters
const textValues = ['row 1', null, 'row 3'];
const numValues = [1, null, 3];
for (let i = 0; i < textValues.length; i++) {
await statement.bind([i + 1, textValues[i], numValues[i]]);
await statement.execute();
}
// get the inserted rows
const rows = await connection.query('select * from dbo.test_parameters order by id');
console.dir([...rows]);
// The result of row 3 has a null value for numValue. Expected the value to be 3!!!.
// close the connection
await connection.rollback();
await connection.close();
}
Additional context
This is the result of retrieving the inserting rows from the table:
[
{ id: 1, textValue: 'row 1', numValue: 1 },
{ id: 2, textValue: null, numValue: null },
{ id: 3, textValue: 'row 3', numValue: null }
]
- 主要言語
- JavaScript
- スター
- 159
- フォーク
- 92
- 平均マージ
- 5時間 59分
- マージ済み PR(30日)
- 3
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
IBM/node-odbc のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
security
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
[Bug] Sybase ASE: Encoding issue (works in msnodesqlv8, fails in node-odbc with \x1A artifacts)オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
似ている issue
-
ci-install-db-tools stall-case tests flake: stalled apt-get can be killed before it logs its callオープンeffort:low model:light plan planner:opus-5-5 tests
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
Bug 🐞
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
mozilla-mobile/firefox-ios#35986 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
component:sight
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
agentic-os-org/ANOLISA#6738 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug Durable Agents Observability (AI Telemetry) status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
mastra-ai/mastra#26470 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信