Skip to content

[BUG] Queries return parse error when using a table alias #425

@mark-faulk

Description

@mark-faulk

Describe your system

  • odbc Package Version: odbc@2.4.9
  • ODBC Driver: MDBTools
  • Database Name: Access
  • Database Version: uncertain
  • Database OS: running through kubuntu using ODBC
  • Node.js Version: v20.15.0
  • Node.js OS: kubuntu 24.04

Describe the bug
I have this code:
const odbc = require('odbc'); const connection = odbc.connect('DSN=my_db', (error, connection) => { connection.query('select * from Objects limit 10', (error, result) => { if (error) { console.error(error) } console.log(result.columns) }); });

which works with no issues. However, if I modify the query with an alias like:

'select * from Objects a1a limit 10'

I get this error:

Got no result for 'select * from Objects a1a limit 10' command [Error: [odbc] Error executing the sql statement] { odbcErrors: [ { state: '', code: 1, message: "Couldn't parse SQL\n" } ] }

In addition, if I put any joins in the query I get the exact same error. For example:

select objects.ID, objects.Object, objects.CardID, objects.SetID, objects.Name, sets.name as set_name from Objects inner join sets on sets.id = Objects.setid where sets.name in ('The Awesome Planet') limit 10

If I run these same queries in DBeaver they return data with no errors.

Expected behavior
The query to parse with no errors.

To Reproduce
Steps to reproduce the behavior:
Described above.

  • The offending code:
  • Any DEBUG information printed to the terminal: Described above
  • Any error information returned from a function call: Described above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions