[BUG] Prepared statement with cursor does not return result in second call with new bind.
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 38/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, sql
- Área
- database
Línea de trabajo
Comienza ejecutando la secuencia proporcionada de createStatement, prepare, bind, execute, cursor.close y rebind contra SQL Server con ODBC Driver 18. Rastrea el estado de los parámetros de la sentencia durante ambas ejecuciones y verifica que el segundo bind se conserve. Se considera terminado cuando el segundo cursor informa de la fila con id 2 y la primera ejecución existente sigue devolviendo id 1.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
}
]
]
- Lenguaje dominante
- JavaScript
- Estrellas
- 159
- Forks
- 92
- Merge medio
- 5 h 59 min
- PR fusionados (30 d)
- 3
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de IBM/node-odbc
-
doc: how to run the testsAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
-
security
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
[Bug] Sybase ASE: Encoding issue (works in msnodesqlv8, fails in node-odbc with \x1A artifacts)Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
Todos los issues de IBM/node-odbc
Issues similares
-
effort:low model:light plan planner:fable-5-1 test-quality tests
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
area: agent area: theme help wanted lane: free-agent roadmap size: S status: needs-brief type: layout type: task
Dificultad 2/5 1-3 horas Aptitud para principiantes 60/100
arminazimi/slipway#64 ·
-
release:v5.34
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Jason-Vaughan/TangleClaw#2469 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
hacktoberfest help wanted skip-changelog
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
wassim-azi/agy-powerline#74 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
MadeBaruna/paimon-moe#696 ·