[BUG] Prepared statement with cursor does not return result in second call with new bind.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 38/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, sql
- Ambito
- database
Direzione di ricerca
Inizia eseguendo la sequenza fornita createStatement, prepare, bind, execute, cursor.close e rebind su SQL Server con ODBC Driver 18. Traccia lo stato dei parametri dell’istruzione durante entrambe le esecuzioni e verifica che il secondo bind venga mantenuto. Il lavoro è completato quando il secondo cursore segnala la riga con id 2 e la prima esecuzione esistente restituisce ancora id 1.
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 (a query) with a single parameter together with a bind for it's value.
The prepared statement is executed as a cursor and an expected result is returned after which the cursor is closed.
A new bind value is passed to the statement and again the statement is executed as a cursor.
In the second execute a result was expected but nothing was returned.
Expected behavior
- A query result in the first call.
- A query result in the second call.
To Reproduce
- create a simple test table and populate with 2 rows: CREATE TABLE test (id int); insert into test values (1), (2);
- Execute the code as given below
Code
const odbc = require('odbc');
async function connectToDatabase() {
const connectionConfig = {
connectionString: 'DSN=MSSQL2019;uid=sa;pwd=iRefact2017;MARS_Connection=no;trustServerCertificate=yes',
connectionTimeout: 10,
loginTimeout: 10
};
const connection = await odbc.connect(connectionConfig);
const statement = await connection.createStatement();
await statement.prepare(`
select * from IR_TSTGIN.dbo.test where id = ?;
`);
await statement.bind([1]);
let cursor = await statement.execute({
fetchSize: 1
});
while (!cursor.noData) {
const result = await cursor.fetch();
console.dir(result, {
depth: null
});
}
await cursor.close();
await statement.bind([2]);
cursor = await statement.execute({
fetchSize: 1
});
while (!cursor.noData) {
const result = await cursor.fetch();
console.dir(result, {
depth: null
});
}
await cursor.close();
}
connectToDatabase()
.catch(error => {
console.dir(error, {
depth: null
});
});
Additional context
The logging of the result returned reveals something interesting: the value of the parameters property in the second execution reports a value [1] where a value 2 was bound. Nevertheless the query does not report a result (if the parameter would have had value 1 it still should have returned a record).
This is the console.log of the result object for the first and second statement:
First statement:
[
{ id: 1 },
statement: '\n select * from IR_TSTGIN.dbo.test where id = ?;\n ',
parameters: [ 1 ],
return: undefined,
count: -1,
columns: [
{
name: 'id',
dataType: 4,
columnSize: 10,
decimalDigits: 0,
nullable: true
}
]
]
Second statement:
[
statement: '\n select * from IR_TSTGIN.dbo.test where id = ?;\n ',
parameters: [ 1 ],
return: undefined,
count: -1,
columns: [
{
name: 'id',
dataType: 4,
columnSize: 10,
decimalDigits: 0,
nullable: true
}
]
]
- 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
-
external-plugin external-plugin-canvas needs-review:MEDIUM ready-for-review
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
github/awesome-copilot#5153 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
sallowayma-git/IELTS-practice#248 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
SecureBananaLabs/bug-bounty#13365 ·
I maintainer di solito rispondono entro 4 giorni