-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
114 changed files
with
1,689 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
let newInsertCommand = require('../table/commands/newInsertCommand'); | ||
let newInsertCommandCore = require('../table/commands/newInsertCommandCore'); | ||
let newGetLastInsertedCommand = require('../table/commands/newGetLastInsertedCommand'); | ||
let executeQueries = require('../table/executeQueries'); | ||
let pushCommand = require('../table/commands/pushCommand'); | ||
|
||
|
||
function insertDefault(table, row, options) { | ||
let commands = []; | ||
let insertCmd = newInsertCommand(newInsertCommandCore, table, row, options); | ||
insertCmd.disallowCompress = true; | ||
pushCommand(insertCmd); | ||
|
||
let selectCmd = newGetLastInsertedCommand(table, row, insertCmd); | ||
commands.push(selectCmd); | ||
|
||
return executeQueries(commands).then((result) => result[result.length - 1]); | ||
|
||
} | ||
|
||
module.exports = insertDefault; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var format = 'delete from %s where %s.rowId in (SELECT %s.rowId FROM %s %s%s)'; | ||
var util = require('util'); | ||
|
||
function deleteFromSql(table, alias, whereSql) { | ||
var name = table._dbName; | ||
return util.format(format, name, name, alias, name, alias, whereSql); | ||
} | ||
module.exports = deleteFromSql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function encodeBoolean(bool) { | ||
if (bool) | ||
return 1; | ||
return 0; | ||
} | ||
|
||
module.exports = encodeBoolean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//unused because using sql parameters instead | ||
//Remove ? | ||
function encodeBuffer(buffer) { | ||
return 'E\'\\\\x' + buffer.toString('hex') + '\''; | ||
} | ||
|
||
module.exports = encodeBuffer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function encodeDate(date) { | ||
if (date.toISOString) | ||
return '\'' + date.toISOString() + '\''; | ||
return '\'' + date + '\''; | ||
} | ||
|
||
module.exports = encodeDate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function formatDateColumn(value) { | ||
return `TO_TIMESTAMP(${value}, 'YYYY-MM-DD"T"HH24:MI:SS.FF3')`; | ||
} | ||
|
||
module.exports = formatDateColumn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
function formatDateColumn(column, alias) { | ||
return `${alias}.${column._dbName}::text`; | ||
return `TO_CHAR(${alias}.${column._dbName}, 'YYYY-MM-DD"T"HH24:MI:SS.FF3')`; | ||
} | ||
|
||
module.exports = formatDateColumn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const newInsertCommand = require('../table/commands/newInsertCommand'); | ||
const newInsertCommandCore = require('./newInsertCommandCore'); | ||
const setSessionSingleton = require('../table/setSessionSingleton'); | ||
const newGetLastInsertedCommand = require('../table/commands/newGetLastInsertedCommand'); | ||
const executeQueries = require('../table/executeQueries'); | ||
|
||
function insert(table, row, options) { | ||
|
||
return new Promise((res, rej) => { | ||
const cmd = newInsertCommand(newInsertCommandCore, table, row, options); | ||
cmd.disallowCompress = true; | ||
executeQueries([cmd]).then((result) => result[0]).then(onResult).then(res, rej); | ||
|
||
function onResult([result]) { | ||
setSessionSingleton('lastRowid', result.lastRowid); | ||
const selectCmd = newGetLastInsertedCommand(table, row, cmd); | ||
return executeQueries([selectCmd]).then((result) => res(result[0])); | ||
} | ||
|
||
}); | ||
} | ||
|
||
module.exports = insert; |
Oops, something went wrong.