Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: AlaSQL/alasql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 841d33607313bf4ce3a2616645dd210968b5415e
Choose a base ref
...
head repository: AlaSQL/alasql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9c29f699f34704b42a62a79cae87e20a95d7285c
Choose a head ref
  • 11 commits
  • 7 files changed
  • 3 contributors

Commits on Jan 16, 2024

  1. chore(deps): update dependency eslint to v8.56.0 (#1838)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jan 16, 2024
    Copy the full SHA
    aeb4b00 View commit details
  2. chore(deps): update dependency open to v10.0.3 (#1857)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jan 16, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    c4bcb0c View commit details
  3. chore(deps): update actions/upload-artifact action to v4 (#1852)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jan 16, 2024
    Copy the full SHA
    282d002 View commit details
  4. chore(deps): update github/codeql-action action to v3 (#1853)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jan 16, 2024
    Copy the full SHA
    b93fd98 View commit details
  5. chore(deps): update dependency lint-staged to v15.2.0 (#1844)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jan 16, 2024
    Copy the full SHA
    fcb7df3 View commit details
  6. Format src

    mathiasrw committed Jan 16, 2024
    Copy the full SHA
    deae651 View commit details

Commits on Jan 17, 2024

  1. Copy the full SHA
    fd40cf4 View commit details
  2. Copy the full SHA
    674b927 View commit details

Commits on Jan 26, 2024

  1. Copy the full SHA
    d78fb1b View commit details
  2. Force minimist resolution

    mathiasrw committed Jan 26, 2024
    Copy the full SHA
    40f8e9c View commit details
  3. v4.2.6

    mathiasrw committed Jan 26, 2024
    Copy the full SHA
    9c29f69 View commit details
Showing with 200 additions and 445 deletions.
  1. +3 −3 .github/workflows/codeql.yml
  2. +2 −2 .github/workflows/scorecard.yml
  3. +9 −7 package.json
  4. +60 −36 src/50expression.js
  5. +2 −2 tslint.json
  6. +17 −0 types/alasql.d.ts
  7. +107 −395 yarn.lock
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -64,7 +64,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -77,6 +77,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
4 changes: 2 additions & 2 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
@@ -59,14 +59,14 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 # v4.1.0
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@c0d1daa7f7e14667747d73a7dbbe8c074bc8bfe2 # v2.22.9
uses: github/codeql-action/upload-sarif@e5f05b81d5b6ff8cfa111c80c22c5fd02a384118 # v3.23.0
with:
sarif_file: results.sarif
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "alasql",
"description": "Use SQL to select and filter javascript data - including relational joins and search in nested objects (JSON). Export to and import from Excel and CSV",
"version": "4.2.5",
"version": "4.2.6",
"author": "Andrey Gershun <agershun@gmail.com>",
"contributors": [
"Mathias Wulff <m@rawu.dk>"
@@ -53,8 +53,8 @@
"blueimp-md5": "2.19.0",
"cmdmix": "2.1.1",
"dom-storage": "2.1.0",
"esbuild": "^0.19.3",
"eslint": "8.53.0",
"esbuild": "0.19.12",
"eslint": "8.56.0",
"eslint-config-standard": "17.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-n": "16.3.1",
@@ -63,11 +63,11 @@
"git-branch-is": "4.0.0",
"husky": "8.0.3",
"jison-gho": "^0.6.1-216",
"lint-staged": "15.1.0",
"lint-staged": "15.2.0",
"mocha": "10.2.0",
"mocha.parallel": "0.15.6",
"open": "10.0.2",
"prettier": "^3.0.3",
"open": "10.0.3",
"prettier": "3.2.4",
"react-native-fetch-blob": "^0.10.8",
"react-native-fs": "^2.20.0",
"rexreplace": "7.1.3",
@@ -82,7 +82,9 @@
"underscore": "1",
"glob-parent": "6",
"decode-uri-component": "0.2",
"semver": "7"
"semver": "7",
"@gerhobbelt/json5": "2.1.0-48",
"minimist": "1.2.6"
},
"engines": {
"node": ">=15"
96 changes: 60 additions & 36 deletions src/50expression.js
Original file line number Diff line number Diff line change
@@ -192,9 +192,29 @@
const toTypeNumberOps = new Set(['-', '*', '/', '%', '^']);
const toTypeStringOps = new Set(['||']);
const toTypeBoolOps = new Set([
'AND', 'OR', 'NOT', '=', '==', '===', '!=', '!==', '!===',
'>', '>=', '<', '<=', 'IN', 'NOT IN', 'LIKE', 'NOT LIKE',
'REGEXP', 'GLOB', 'BETWEEN', 'NOT BETWEEN', 'IS NULL', 'IS NOT NULL'
'AND',
'OR',
'NOT',
'=',
'==',
'===',
'!=',
'!==',
'!===',
'>',
'>=',
'<',
'<=',
'IN',
'NOT IN',
'LIKE',
'NOT LIKE',
'REGEXP',
'GLOB',
'BETWEEN',
'NOT BETWEEN',
'IS NULL',
'IS NOT NULL',
]);
class Op {
constructor(params) {
@@ -227,7 +247,6 @@
return `${leftStr} ${this.op} ${this.allsome ? this.allsome + ' ' : ''}${this.right.toString()}`;
}


findAggregator(query) {
if (this.left && this.left.findAggregator) {
this.left.findAggregator(query);
@@ -239,13 +258,9 @@
}

toType(tableid) {
if (toTypeNumberOps.has(this.op))
return 'number';


if (toTypeStringOps.has(this.op))
return 'string';
if (toTypeNumberOps.has(this.op)) return 'number';

if (toTypeStringOps.has(this.op)) return 'string';

if (this.op === '+') {
const leftType = this.left.toType(tableid);
@@ -259,18 +274,13 @@
}
}

if (toTypeBoolOps.has(this.op) || this.allsome)
return 'boolean';


if (!this.op)
return this.left.toType(tableid);
if (toTypeBoolOps.has(this.op) || this.allsome) return 'boolean';

if (!this.op) return this.left.toType(tableid);

return 'unknown';
}


toJS(context, tableid, defcols) {
// console.log(this);
var s;
@@ -556,7 +566,6 @@
op = '&&';
}


var expr = s || '(' + leftJS() + op + rightJS() + ')';

var declareRefs = 'y=[(' + refs.join('), (') + ')]';
@@ -724,7 +733,7 @@
'~': '~',
'-': '-',
'+': '+',
'NOT': '!',
NOT: '!',
};

class UniOp {
@@ -733,7 +742,7 @@
}

toString() {
const { op, right } = this;
const {op, right} = this;
const res = right.toString();

switch (op) {
@@ -767,8 +776,6 @@
}
}



toJS(context, tableid, defcols) {
if (this.right instanceof Column && this.op === '#') {
return `(alasql.databases[alasql.useid].objects['${this.right.columnid}'])`;
@@ -786,10 +793,8 @@

throw new Error(`Unsupported operator: ${this.op}`);
}

}


class Column {
constructor(params) {
assign(this, params);
@@ -813,38 +818,52 @@
return s;
}


toJS(context, tableid, defcols) {
if (!this.tableid && tableid === '' && !defcols) {
return this.columnid !== '_' ? `${context}['${this.columnid}']` : (context === 'g' ? "g['_']" : context);
return this.columnid !== '_'
? `${context}['${this.columnid}']`
: context === 'g'
? "g['_']"
: context;
}

if (context === 'g') {
return `g['${this.nick}']`;
}

if (this.tableid) {
return this.columnid !== '_' ? `${context}['${this.tableid}']['${this.columnid}']` : (context === 'g' ? "g['_']" : `${context}['${this.tableid}']`);
return this.columnid !== '_'
? `${context}['${this.tableid}']['${this.columnid}']`
: context === 'g'
? "g['_']"
: `${context}['${this.tableid}']`;
}

if (defcols) {
const tbid = defcols[this.columnid];
if (tbid === '-') {
throw new Error(`Cannot resolve column "${this.columnid}" because it exists in two source tables`);
throw new Error(
`Cannot resolve column "${this.columnid}" because it exists in two source tables`
);
} else if (tbid) {
return this.columnid !== '_' ? `${context}['${tbid}']['${this.columnid}']` : `${context}['${tbid}']`;
return this.columnid !== '_'
? `${context}['${tbid}']['${this.columnid}']`
: `${context}['${tbid}']`;
} else {
return this.columnid !== '_' ? `${context}['${this.tableid || tableid}']['${this.columnid}']` : `${context}['${this.tableid || tableid}']`;
return this.columnid !== '_'
? `${context}['${this.tableid || tableid}']['${this.columnid}']`
: `${context}['${this.tableid || tableid}']`;
}
}

if (tableid === -1) {
return `${context}['${this.columnid}']`;
}

return this.columnid !== '_' ? `${context}['${this.tableid || tableid}']['${this.columnid}']` : `${context}['${this.tableid || tableid}']`;
return this.columnid !== '_'
? `${context}['${this.tableid || tableid}']['${this.columnid}']`
: `${context}['${this.tableid || tableid}']`;
}

}

class AggrValue {
@@ -853,15 +872,17 @@
}

toString() {
const funcName = this.aggregatorid === 'REDUCE' ? this.funcid.replace(re_invalidFnNameChars, '') : this.aggregatorid;
const funcName =
this.aggregatorid === 'REDUCE'
? this.funcid.replace(re_invalidFnNameChars, '')
: this.aggregatorid;
const distinctPart = this.distinct ? 'DISTINCT ' : '';
const expressionPart = this.expression ? this.expression.toString() : '';
const overPart = this.over ? ` ${this.over.toString()}` : '';

return `${funcName}(${distinctPart}${expressionPart})${overPart}`;
}


findAggregator(query) {
const colas = escapeq(this.toString()) + ':' + query.selectGroup.length;

@@ -876,9 +897,12 @@
query.selectGroup.push(this);
}


toType() {
if (['SUM', 'COUNT', 'AVG', 'MIN', 'MAX', 'AGGR', 'VAR', 'STDDEV', 'TOTAL'].includes(this.aggregatorid)) {
if (
['SUM', 'COUNT', 'AVG', 'MIN', 'MAX', 'AGGR', 'VAR', 'STDDEV', 'TOTAL'].includes(
this.aggregatorid
)
) {
return 'number';
}

4 changes: 2 additions & 2 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"rules": {
"interface-name": [true, "never-prefix"],
"whitespace": [false]
}
"whitespace": [false],
},
}
17 changes: 17 additions & 0 deletions types/alasql.d.ts
Original file line number Diff line number Diff line change
@@ -138,6 +138,22 @@ declare module 'alasql' {
[tableName: string]: table;
}

interface Database {
databaseid: string;
dbversion: number;
tables: {[key: string]: any};
views: {[key: string]: any};
triggers: {[key: string]: any};
indices: {[key: string]: any};
objects: {[key: string]: any};
counter: number;
sqlCache: {[key: string]: any};
sqlCacheSize: number;
astCache: {[key: string]: any};
resetSqlCache: () => void;
exec: (sql: string, params?: object, cb?: Function) => any;
autoval: (tablename: string, colname: string, getNext: boolean) => any;
}
interface AlaSQL {
options: AlaSQLOptions;
error: Error;
@@ -150,6 +166,7 @@ declare module 'alasql' {
autoval(tablename: string, colname: string, getNext?: boolean): number;
yy: {};
setXLSX(xlsxlib: typeof xlsx): void;
Database: Database;

/**
* Array of databases in the AlaSQL object.
502 changes: 107 additions & 395 deletions yarn.lock

Large diffs are not rendered by default.