AlaSQL / alasql

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
http://alasql.org
MIT License
7.04k stars 659 forks source link

Bug in ORDER BY 1 #125

Open agershun opened 9 years ago

agershun commented 9 years ago

This sequence

    alasql('SELECT * FROM TSV("sensor_data.txt",{headers:true}) ORDER BY 1',[],function(res){
        console.log(res);
    });

gives error:

    alasql.min.js:5 Uncaught TypeError: Cannot read property 'reduced' of undefined
    yy.Expression.toJavaScriptalasql.min.js:5 (anonymous function)
    yy.Select.compileOrder
agershun commented 9 years ago

:) The problem was that I sed star in the query. AlaSQL could not find any column name, of course. Now all works fine.

agershun commented 9 years ago

Sample:

     -- works fine
      var res = alasql('SELECT COLUMN DISTINCT city#country#name AS country\
           FROM Person ORDER BY country');

     -- does not work
       var res = alasql('SELECT COLUMN DISTINCT city#country#name\
           FROM Person ORDER BY 1');

error

     ReferenceError: alasql is not defined 
mathiasrw commented 8 years ago

Can you elaborate on the # part of the city#country#name notation?