[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
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, node.js
Direzione di ricerca
Esegui la riproduzione Node.js fornita e inizia dalle chiamate a statement.bind e statement.execute, concentrandoti su come i parametri vengono riutilizzati tra le iterazioni del ciclo. Il lavoro è completato quando la terza riga inserita conserva il valore numerico associato 3 dopo che la seconda riga associa null.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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 }
]
- Lingua principale
- JavaScript
- Stelle
- 159
- Fork
- 92
- Merge medio
- 5h 59m
- PR unite (30g)
- 3
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di IBM/node-odbc
-
doc: how to run the testsAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
security
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
[Bug] Sybase ASE: Encoding issue (works in msnodesqlv8, fails in node-odbc with \x1A artifacts)Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
Tutte le issue di IBM/node-odbc
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
NaturalIntelligence/fast-xml-parser#888 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
bug callouts regression revealjs
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
quarto-dev/quarto-cli#15014 ·
I maintainer di solito rispondono entro 1 giorno
-
Remove: Fox Deportes SDApertacheck:passed feeds:remove
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
iptv-org/database#37176 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 9 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
hawk-digital-environments/HAWKI#443 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
modelcontextprotocol/python-sdk#3662 ·
I maintainer di solito rispondono entro 1 giorno