Skip to content

Commit

Permalink
Merge pull request #36 from benjaminVadon/master
Browse files Browse the repository at this point in the history
Add replace SQL statement
  • Loading branch information
xavierlacot committed Mar 7, 2013
2 parents 931bea4 + 7a261b6 commit aedb75e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions joli.js
Expand Up @@ -493,6 +493,8 @@ var joliCreator = function() {
return 'delete from ' + this.data.from;
case 'insert_into':
return 'insert into ' + this.data.from + ' (' + this.data.set.join(', ') + ') values (' + this.data.values.join(', ') + ')';
case 'replace':
return 'replace into ' + this.data.from + ' (' + this.data.set.join(', ') + ') values (' + this.data.values.join(', ') + ')';
case 'select':
var join = '';

Expand All @@ -509,7 +511,7 @@ var joliCreator = function() {
case 'update':
return 'update ' + this.data.from + ' set ' + this.data.set.join(', ');
default:
throw ("Operation type Error. joli.query operation type must be an insert, a delete, a select or an update.");
throw ("Operation type Error. joli.query operation type must be an insert, a delete, a select, a replace or an update.");
}
},
getQuery: function() {
Expand Down Expand Up @@ -667,6 +669,11 @@ var joliCreator = function() {
this.data.order = order;
return this;
},
replace: function(table) {
this.data.operation = 'replace';
this.data.from = table;
return this;
},
select: function(columns) {
this.data.operation = 'select';

Expand Down Expand Up @@ -894,4 +901,4 @@ if (typeof exports === 'object' && exports) {

return joli;
};
}
}

0 comments on commit aedb75e

Please sign in to comment.