Skip to content

Commit 41d7c42

Browse files
committed
trigger build - improved code climate
1 parent 12bcec3 commit 41d7c42

File tree

3 files changed

+60
-62
lines changed

3 files changed

+60
-62
lines changed

jSQL.js

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -399,39 +399,36 @@ function jSQLTable(name, columns, data, types, keys, auto_increment){
399399
unique: []
400400
};
401401

402-
// Create the table and load the data, if there is any
403-
self.init = function(name, columns, data, types, keys, auto_increment){
404-
self.name = name;
405-
406-
// If the types array does not exist, create it
407-
if(undefined === types) types = [];
408-
409-
// If first param is array, no third param
410-
if(Array.isArray(columns) && undefined === data)
411-
// Create the data parameter from column param
412-
{data = columns; columns = [];}
413-
414-
// If second param is array of objects
415-
// - Create table from first object
416-
// - Generate data (3rd) param
417-
if(Array.isArray(columns) && !Array.isArray(columns[0]) && typeof columns[0]==="object"){
418-
var cols = [], n;
419-
for(n in columns[0])
420-
if(columns[0].hasOwnProperty(n))
421-
cols.push(n);
422-
data = columns;
423-
columns = cols;
424-
}
402+
self.name = name;
403+
404+
// If the types array does not exist, create it
405+
if(undefined === types) types = [];
406+
407+
// If first param is array, no third param
408+
if(Array.isArray(columns) && undefined === data)
409+
// Create the data parameter from column param
410+
{data = columns; columns = [];}
411+
412+
// If second param is array of objects
413+
// - Create table from first object
414+
// - Generate data (3rd) param
415+
if(Array.isArray(columns) && !Array.isArray(columns[0]) && typeof columns[0]==="object"){
416+
var cols = [], n;
417+
for(n in columns[0])
418+
if(columns[0].hasOwnProperty(n))
419+
cols.push(n);
420+
data = columns;
421+
columns = cols;
422+
}
425423

426-
self.initColumns(columns, types);
424+
self.initColumns(columns, types);
427425

428-
self.initKeys(keys, auto_increment);
426+
self.initKeys(keys, auto_increment);
429427

430-
// Load the data, if there is any
431-
if(data !== undefined) self.loadData(data);
432-
};
428+
self.initAI(auto_increment);
433429

434-
self.init(name, columns, data, types, keys, auto_increment);
430+
// Load the data, if there is any
431+
if(data !== undefined) self.loadData(data);
435432
}
436433

437434
jSQLTable.prototype.initColumns = function(columns, types){
@@ -457,7 +454,7 @@ jSQLTable.prototype.initColumns = function(columns, types){
457454
for(i=0; i<columns.length; i++) this.colmap[columns[i]] = i;
458455
};
459456

460-
jSQLTable.prototype.initKeys = function(keys, auto_increment){
457+
jSQLTable.prototype.initKeys = function(keys){
461458
// Set up keys if key data is provided
462459
var key;
463460
var keyTypes = ["primary", "unique"];
@@ -474,7 +471,9 @@ jSQLTable.prototype.initKeys = function(keys, auto_increment){
474471
if(type === "primary") this.keys.primary.column = key.column;
475472
if(type === "unique") this.keys.unique.push({column:key.column, map:{}});
476473
}
474+
};
477475

476+
jSQLTable.prototype.initAI = function(auto_increment){
478477
// if there's an AI column
479478
if(auto_increment){
480479
var isInPKArray = Array.isArray(this.keys.primary.column) && this.keys.primary.column.indexOf(auto_increment) > -1;
@@ -647,7 +646,7 @@ jSQLTable.prototype.updateKeysOnInsert = function(row, ignore){
647646

648647
// Check the unique keys, There may be multiple and they may be compound
649648
for(var k=0, ukey; k<this.keys.unique.length; k++){
650-
ukey=this.keys.unique[k]
649+
ukey=this.keys.unique[k];
651650
var key_columns = Array.isArray(ukey.column) ? ukey.column : [ukey.column];
652651
var col, vals = [];
653652
for(var uk=0; uk<key_columns.length; uk++){

jSQL.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/table/jSQLTable.js

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,36 @@ function jSQLTable(name, columns, data, types, keys, auto_increment){
1515
unique: []
1616
};
1717

18-
// Create the table and load the data, if there is any
19-
self.init = function(name, columns, data, types, keys, auto_increment){
20-
self.name = name;
21-
22-
// If the types array does not exist, create it
23-
if(undefined === types) types = [];
24-
25-
// If first param is array, no third param
26-
if(Array.isArray(columns) && undefined === data)
27-
// Create the data parameter from column param
28-
{data = columns; columns = [];}
29-
30-
// If second param is array of objects
31-
// - Create table from first object
32-
// - Generate data (3rd) param
33-
if(Array.isArray(columns) && !Array.isArray(columns[0]) && typeof columns[0]==="object"){
34-
var cols = [], n;
35-
for(n in columns[0])
36-
if(columns[0].hasOwnProperty(n))
37-
cols.push(n);
38-
data = columns;
39-
columns = cols;
40-
}
18+
self.name = name;
19+
20+
// If the types array does not exist, create it
21+
if(undefined === types) types = [];
22+
23+
// If first param is array, no third param
24+
if(Array.isArray(columns) && undefined === data)
25+
// Create the data parameter from column param
26+
{data = columns; columns = [];}
27+
28+
// If second param is array of objects
29+
// - Create table from first object
30+
// - Generate data (3rd) param
31+
if(Array.isArray(columns) && !Array.isArray(columns[0]) && typeof columns[0]==="object"){
32+
var cols = [], n;
33+
for(n in columns[0])
34+
if(columns[0].hasOwnProperty(n))
35+
cols.push(n);
36+
data = columns;
37+
columns = cols;
38+
}
4139

42-
self.initColumns(columns, types);
40+
self.initColumns(columns, types);
4341

44-
self.initKeys(keys, auto_increment);
42+
self.initKeys(keys, auto_increment);
4543

46-
// Load the data, if there is any
47-
if(data !== undefined) self.loadData(data);
48-
};
44+
self.initAI(auto_increment);
4945

50-
self.init(name, columns, data, types, keys, auto_increment);
46+
// Load the data, if there is any
47+
if(data !== undefined) self.loadData(data);
5148
}
5249

5350
jSQLTable.prototype.initColumns = function(columns, types){
@@ -73,7 +70,7 @@ jSQLTable.prototype.initColumns = function(columns, types){
7370
for(i=0; i<columns.length; i++) this.colmap[columns[i]] = i;
7471
};
7572

76-
jSQLTable.prototype.initKeys = function(keys, auto_increment){
73+
jSQLTable.prototype.initKeys = function(keys){
7774
// Set up keys if key data is provided
7875
var key;
7976
var keyTypes = ["primary", "unique"];
@@ -90,7 +87,9 @@ jSQLTable.prototype.initKeys = function(keys, auto_increment){
9087
if(type === "primary") this.keys.primary.column = key.column;
9188
if(type === "unique") this.keys.unique.push({column:key.column, map:{}});
9289
}
90+
};
9391

92+
jSQLTable.prototype.initAI = function(auto_increment){
9493
// if there's an AI column
9594
if(auto_increment){
9695
var isInPKArray = Array.isArray(this.keys.primary.column) && this.keys.primary.column.indexOf(auto_increment) > -1;

0 commit comments

Comments
 (0)