Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[BUG] Cursor with fetchSize > 1 results in error on prepared statement

Đang mở
#329 8 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, node.js, sql
Lĩnh vực
database

Hướng nghiên cứu

Start by reproducing the prepared-statement path using statement.prepare, statement.execute({ fetchSize: 2 }), and cursor.fetch against SQL Server. Compare it with execution without a prepared statement and trace the cursor handling that produces the "Invalid cursor position" error. Done means fetchSize greater than 1 works with prepared statements and preserves regular cursor behavior.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

confirmed

Describe your system

  • odbc Package Version: 2.4.7
  • ODBC Driver: Microsoft ODBC Driver Version 18
  • Database Name: SQLServer
  • Database Version: 2019
  • Database OS: Windows
  • Node.js Version: 16.15.1
  • Node.js OS: Mac OS Ventura 13.3

Describe the bug
The ODBC driver returns a "Invalid cursor position" error if a fetchSize > 1 is specified for a prepared statement in statement.execute.

Expected behavior
Regular cursor behaviour when specifying a fetchSize > 1

To Reproduce

  1. Create a simple test table: CREATE TABLE test (id int);
  2. Insert some rows: INSERT INTO test values (1),(2),(3),(4),(5);
  3. Execute the code as specified below. This will result in the described error.

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;');
    let cursor = await statement.execute({
        fetchSize: 2
    });
    let result = await cursor.fetch();
    await cursor.close();
}

connectToDatabase()
    .catch(error => {
        console.dir(error, {
            depth: null
        });
    });

Additional context

Specifying a fetchSize without a prepared statement does return as expected. So it seems that something goes wrong with a cursor on a prepared statement.

Ngôn ngữ chính
JavaScript
Star
159
Fork
92
Merge trung bình
5 giờ 59 phút
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của IBM/node-odbc

Tất cả issue của IBM/node-odbc

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.