wankdanker / node-odbc

ODBC bindings for node
MIT License
174 stars 79 forks source link

Fetch-Mode is undocumented ( and doesn't work? ) #78

Closed nickperkinslondon closed 3 years ago

nickperkinslondon commented 5 years ago

The documentation alludes to a connection option that allows returning either OBJECTS or ARRAYS. Looking at the source code seems to indicate that the option "fetchMode:3" might generate ARRAYS....but it doesn't -- I still get objects. Does the option work? Can we have an example?

markdirish commented 5 years ago

Which version of odbc are you using? It should be working in 1.x, but it seems like it isn't in 2.x. It should be really easy to add though, all result sets go through the same function so I only have to touch a little bit of code. I'll see what I can do tonight.

markdirish commented 5 years ago

Ok, I have pushed 2.1.3. When you create a connection, you can do:

const connection = await odbc.connect({
    connectionString: 'YourConnectionString',
    fetchArray: true
  });

And now your result sets will be an array of arrays, instead of an array of objects

wankdanker commented 3 years ago

@nickperkinslondon If you are stilling using odbc@^1, examples for how to do this are in these tests:

The tests do pass, so it does appear to work.