Skip to content

Sorting does not occur for field names in Latin or in quotation marks! #2039

Closed

Description

@StarfairStudio

When creating a SQL query to Excel tables, if the column names are not in Latin, then you cannot sort using 'order by' if the column name is used without quotes (a syntax error occurs):
let sql="select recordset * from xlsx('c:\\MyTable.xlsx') order by Поле";//syntax error

In the case of using quotes, this function simply does not work, since it is not the contents of the field that are compared, but its name, and they are always equal to each other for the compared rows when sorting inside AlaSQL:
let sql="select recordset * from xlsx('c:\\MyTable.xlsx') order by 'Поле'";//Sorting does not occur!

Activity

  1. StarfairStudio commented on Jan 21, 2025

    @StarfairStudio
    Author

    I think I found a solution. It works if you pack the name of the required columns in square brackets:
    let sql="select recordset * from xlsx('c:\\MyTable.xlsx') order by [Поле]";//All ok!

  2. mathiasrw commented on Jan 22, 2025

    @mathiasrw
    Member

    I am very happy that you found this solution. However, ill keep it open to allow anyone to provide a fix.

  3. StarfairStudio commented on Jan 23, 2025

    @StarfairStudio
    Author

    I agree! You have a great library, but sometimes you have needs like the one I described, and it would be great to be able to make queries without escaping the column names!

  4. mathiasrw commented on Feb 28, 2025

    @mathiasrw
    Member

    AlaSQL bot answer


    You're getting the error "Path to alasql.js is not specified" because alasql.worker() needs an explicit path to the alasql.js file when running inside a web worker.

    Solution:

    Specify the path to alasql.js like this:

    import alasql from 'alasql';
    
    alasql.worker('/path/to/alasql.js'); // Make sure the correct path is set

    Example Usage in a Web Worker:

    1. Create a worker script (alasql-worker.js):
    importScripts('/path/to/alasql.js');
    
    self.onmessage = function (e) {
        const { id, sql, params } = e.data;
        alasql.promise(sql, params).then((res) => {
            postMessage({ id, result: res });
        });
    };
    1. In your React component:
    import { useEffect } from 'react';
    
    const worker = new Worker(new URL('./alasql-worker.js', import.meta.url));
    
    export default function MyComponent() {
        useEffect(() => {
            worker.onmessage = (event) => {
                console.log('Query result:', event.data.result);
            };
    
            worker.postMessage({
                id: 1,
                sql: 'SELECT * FROM ?',
                params: [[{ a: 1 }, { a: 2 }]]
            });
        }, []);
    
        return <div>Check the console for results</div>;
    }

    Key Fix:

    • Make sure /path/to/alasql.js is the correct location relative to your project.
    • If using Webpack/Vite, you might need to adjust the worker import.

    Let me know if it works.

  5. added a commit that references this issue on Nov 30, 2025
    b891e4f
  6. mathiasrw commented on Dec 6, 2025

    @mathiasrw
    Member

    Fix released as part of v4.11.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions