Skip to content

Commit 6dd2fb8

Browse files
committed
addressed issue #18 - fixed support for negative integers and floats - force check for floats before ints - improved coverage, added testing for export and import functionality - other minor fixes/improvements
1 parent 2dccd92 commit 6dd2fb8

File tree

9 files changed

+63
-21
lines changed

9 files changed

+63
-21
lines changed

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ module.exports = function(grunt) {
8989
},
9090
options: {
9191
replacements: [{
92-
pattern: /\d.\d.\d/g,
92+
pattern: /\d+.\d+.\d+/g,
9393
replacement: '<%= pkg.version %>'
9494
}]
9595
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright {yyyy} {name of copyright owner}
189+
Copyright 2018 Rob Parham
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![jSQL Logo](http://i.imgur.com/VQlJKOc.png)](http://pamblam.github.io/jSQL/)
22

3-
jSQL (Official) - Version 3.2.2 - *Now available without a prescription!*
3+
jSQL (Official) - Version 3.2.9 - *Now available without a prescription!*
44

55
[![npm version](https://badge.fury.io/js/jsql-official.svg)](https://badge.fury.io/js/jsql-official) [![Build Status](https://travis-ci.org/Pamblam/jSQL.svg?branch=master)](https://travis-ci.org/Pamblam/jSQL) [![Inline docs](http://inch-ci.org/github/Pamblam/jSQL.svg?branch=master)](https://github.com/Pamblam/jSQL/wiki) [![Coverage Status](https://coveralls.io/repos/github/Pamblam/jSQL/badge.svg?branch=master)](https://coveralls.io/github/Pamblam/jSQL?branch=master)
66

@@ -81,7 +81,7 @@ jSQL is fully documented in the [jSQL Wiki](https://github.com/Pamblam/jSQL/wiki
8181

8282
## Browser Support
8383

84-
Works in basically all browsers. jSQL degrades gracefully because it falls back on cookies for persistence if localStorage, IndexedDB and WebSQL are not available. To that end, the library itself does not take advantage of any ES6 features, if you want something that does, have a look at [alaSQL](https://github.com/agershun/alasql).
84+
Works in basically all browsers. jSQL degrades gracefully because it falls back on cookies for persistence if localStorage, IndexedDB and WebSQL are not available.
8585

8686
While jSQL will work in basically all browsers, these ones are preferred:
8787

jSQL.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* jsql-official - v3.2.2
2+
* jsql-official - v3.2.9
33
* A persistent SQL database.
44
* @author Rob Parham
55
* @website http://pamblam.github.io/jSQL/
@@ -1028,15 +1028,15 @@ function jSQLUpdateQuery(){
10281028
if(!this.table.keys.primary.map.hasOwnProperty(col) ||
10291029
this.table.keys.primary.map[col] != new_rows[i].rowIndex) continue;
10301030
delete this.table.keys.primary.map[col];
1031-
this.table.keys.primary.map[new_rows[i].pk_vals] = rowIndex;
1031+
this.table.keys.primary.map[new_rows[i].pk_vals] = new_rows[i].rowIndex;
10321032
break;
10331033
}
10341034
for(var k=0; ukey=this.table.keys.unique[k]; k++){
10351035
for(var col in this.table.keys.unique[k].map){
10361036
if(!this.table.keys.unique[k].map.hasOwnProperty(col) ||
10371037
this.table.keys.unique[k].map[col] != new_rows[i].rowIndex) continue;
10381038
delete this.table.keys.unique[k].map[col];
1039-
this.table.keys.unique[k].map[new_rows[i].uni_vals[k]] = rowIndex;
1039+
this.table.keys.unique[k].map[new_rows[i].uni_vals[k]] = new_rows[i].rowIndex;
10401040
break;
10411041
}
10421042
}
@@ -1156,12 +1156,12 @@ jSQLLexer.token_types = [
11561156
name: "WHITESPACE"},
11571157

11581158
// NUMBERs
1159-
{pattern: /\d+/g,
1160-
type: 'NUMBER',
1161-
name: 'INTEGER'},
1162-
{pattern: /\d+.\.\d+/g,
1159+
{pattern: /[?-]?\d+.\.\d+/g,
11631160
type: 'NUMBER',
11641161
name: 'FLOAT'},
1162+
{pattern: /[?-]?\d+/g,
1163+
type: 'NUMBER',
1164+
name: 'INTEGER'},
11651165

11661166
// QUALIFIERs
11671167
{pattern: /if not exists/gi,
@@ -2816,7 +2816,7 @@ function jsql_import(dump){
28162816
}
28172817

28182818
return {
2819-
version: "3.2.2",
2819+
version: "3.2.9",
28202820
tables: {},
28212821
query: jSQLParseQuery,
28222822
createTable: createTable,

jSQL.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsql-official",
3-
"version": "3.2.2",
3+
"version": "3.3.0",
44
"description": "A persistent SQL database.",
55
"main": "jSQL.min.js",
66
"directories": {

src/lexer/token_types.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ jSQLLexer.token_types = [
2626
name: "WHITESPACE"},
2727

2828
// NUMBERs
29-
{pattern: /\d+/g,
30-
type: 'NUMBER',
31-
name: 'INTEGER'},
32-
{pattern: /\d+.\.\d+/g,
29+
{pattern: /[?-]?\d+.\.\d+/g,
3330
type: 'NUMBER',
3431
name: 'FLOAT'},
32+
{pattern: /[?-]?\d+/g,
33+
type: 'NUMBER',
34+
name: 'INTEGER'},
3535

3636
// QUALIFIERs
3737
{pattern: /if not exists/gi,

src/query_types/jSQLUpdateQuery.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ function jSQLUpdateQuery(){
9696
if(!this.table.keys.primary.map.hasOwnProperty(col) ||
9797
this.table.keys.primary.map[col] != new_rows[i].rowIndex) continue;
9898
delete this.table.keys.primary.map[col];
99-
this.table.keys.primary.map[new_rows[i].pk_vals] = rowIndex;
99+
this.table.keys.primary.map[new_rows[i].pk_vals] = new_rows[i].rowIndex;
100100
break;
101101
}
102102
for(var k=0; ukey=this.table.keys.unique[k]; k++){
103103
for(var col in this.table.keys.unique[k].map){
104104
if(!this.table.keys.unique[k].map.hasOwnProperty(col) ||
105105
this.table.keys.unique[k].map[col] != new_rows[i].rowIndex) continue;
106106
delete this.table.keys.unique[k].map[col];
107-
this.table.keys.unique[k].map[new_rows[i].uni_vals[k]] = rowIndex;
107+
this.table.keys.unique[k].map[new_rows[i].uni_vals[k]] = new_rows[i].rowIndex;
108108
break;
109109
}
110110
}

test/test5.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
var expect = require('chai').expect;
2+
var jSQL = require("../jSQL.js");
3+
4+
jSQL.load(()=>{
5+
jSQL.query("-- Generated with jSQL Devel on Tuesday, February 6th 2018, 3:31pm \n\
6+
CREATE TABLE IF NOT EXISTS `testeroo` (\n\
7+
`id` INT(5) NOT NULL,\n\
8+
`name` VARCHAR(5) NULL,\n\
9+
`another_id` NUMERIC(6) NOT NULL,\n\
10+
`uni1` INT(3) NOT NULL UNIQUE KEY,\n\
11+
`uni2` INT(3) NOT NULL UNIQUE KEY,\n\
12+
PRIMARY KEY (`id`, `another_id`)\n\
13+
)").execute();
14+
15+
var sql = "insert into testeroo values(?, ?, ?, ?, ?)";
16+
jSQL.query(sql).execute([0,'farts',1,5,9]);
17+
jSQL.query(sql).execute([1,'tird',2,6,8]);
18+
jSQL.query(sql).execute([1,'berb',3,7,7]);
19+
jSQL.query(sql).execute([5,'farts',4,1,6]);
20+
21+
var exp = jSQL.export(true, ['testeroo']);
22+
23+
jSQL.reset();
24+
25+
setTimeout(()=>{
26+
jSQL.import(exp);
27+
28+
describe('Export Test', function () {
29+
30+
it('Testing Export up in this biaaatch', function(){
31+
var q = jSQL.query("select * from testeroo where id = 1").execute().fetchAll("ASSOC").length;
32+
expect(q.length === 2).to.be.true;
33+
});
34+
35+
});
36+
}, 1000);
37+
38+
39+
});
40+
41+
42+

0 commit comments

Comments
 (0)