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

TypeError: Cannot read property 'undefined' of undefined #792

Open Eivlys opened 7 years ago

Eivlys commented 7 years ago

I'm using alasql with AngularJs , and include it in the comment way before requireJS:

<script src="vendor/alasql/alasql.min.js" ></script>
<script src="vendor/alasql/xlsx.core.min.js"></script>

but i got an error in the console:

TypeError: Cannot read property 'undefined' of undefined
    at eval [as intoallfn] (eval at <anonymous> (http://cdn.jsdelivr.net/alasql/0.3/alasql.min.js:11:15782), <anonymous>:3:48)
    at c (http://cdn.jsdelivr.net/alasql/0.3/alasql.min.js:2:10846)
    at u (http://cdn.jsdelivr.net/alasql/0.3/alasql.min.js:2:7524)
    at Object.eval [as datafn] (eval at <anonymous> (http://cdn.jsdelivr.net/alasql/0.3/alasql.min.js:11:19335), <anonymous>:3:57)
    at http://cdn.jsdelivr.net/alasql/0.3/alasql.min.js:2:7052
    at Array.forEach (native)
    at o (http://cdn.jsdelivr.net/alasql/0.3/alasql.min.js:2:7012)
    at a (http://cdn.jsdelivr.net/alasql/0.3/alasql.min.js:11:15885)
    at Function.y.dexec (http://cdn.jsdelivr.net/alasql/0.3/alasql.min.js:10:23955)
    at Function.y.exec (http://cdn.jsdelivr.net/alasql/0.3/alasql.min.js:10:23392)

what can i do to fix this?

mathiasrw commented 7 years ago

Are you running any code to get the error?

Eivlys commented 7 years ago

I'm running alasql('SELECT * INTO XLSX("current.xlsx",{headers:true}) FROM ?',[$scope.exportList]);

$scope.exportList is the data i got from node server

mathiasrw commented 7 years ago

What format is the data from the node server?

Eivlys commented 7 years ago

the data is an object [ object, object, object ] ,like: [ { name:'A', id: 1 }, { name: 'B', id: 2 }, { name: 'C', id: 3 } ]

mathiasrw commented 7 years ago

What do you get if you do a

alasql('SELECT * INTO XLSX("current.xlsx",{headers:true}) FROM ?',[[ { name:'A', id: 1 }, { name: 'B', id: 2 }, { name: 'C', id: 3 } ]]);

?

Eivlys commented 7 years ago

well if use[ { name:'A', id: 1 }, { name: 'B', id: 2 }, { name: 'C', id: 3 } ] ,I can get the excel correctly. so there is something wrong with the data i got, what form it should be?

mathiasrw commented 7 years ago

I dont know what to say. if $scope.exportList is truely in the format of [ { name:'A', id: 1 }, { name: 'B', id: 2 }, { name: 'C', id: 3 } ] it does not make sense that its not working?

bkwdesign commented 3 years ago

I am having the same issue nearly. This dead simple JSFiddle works for me just fine, and is how I discovered this library

When I use the exact CDN scripts and paste in the exact contents of the fiddle (except I've moved the function out of the "window" object and attached it to my Knockout.js page model object) the error is what I get

mathiasrw commented 3 years ago

Have you guys had a look at https://github.com/agershun/alasql/wiki/Angular.js ?