Skip to content

Commit

Permalink
release v - 1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwalguptaofficial committed Jul 27, 2020
1 parent 068725b commit 80b4dc4
Show file tree
Hide file tree
Showing 10 changed files with 2,197 additions and 1,949 deletions.
60 changes: 28 additions & 32 deletions dist/grammar.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,24 @@ version = VERSION _* val:Number {
}
}
insertQuery = INSERT _ INTO _ table: tableName _* VALUES _* insertValue: valueTypes _* options: insertOptions* {
var skipDataCheck = false;
var returnValue = false;
let option = {};
options.forEach(val=>{
var key = Object.keys(val)[0];
switch(key){
case 'skipDataCheck':
skipDataCheck = val[key]; break;
option.skipDataCheck = val[key]; break;
case 'return':
returnValue = val[key]; break;
option.return = val[key]; break;
case 'upsert':
option.upsert = val[key]; break;
}
});
return {
api: 'insert',
data: {
into: table,
values: insertValue,
skipDataCheck: skipDataCheck,
return : returnValue
...option
}
}
}
Expand Down Expand Up @@ -171,7 +171,7 @@ insertWithEqual = "=" insertValue: value {
return insertValue;
}

insertOptions = option:(skipDataCheck/return)_* {
insertOptions = option:(skipDataCheck/return/upsert)_* {
return {
[option]:true
}
Expand All @@ -185,6 +185,10 @@ return = RETURN{
return 'return';
}

upsert = UPSERT{
return 'upsert';
}




Expand All @@ -201,50 +205,44 @@ removeQuery = DELETE _* FROM _ table:tableName _* where:whereQry? _* {


countQuery = COUNT _ ("*"_)? FROM _ table:tableName _* where:whereQry? _*
option:(distinct/groupBy)* {
var distinct = false;
var groupBy = null;
option.forEach(val=>{
options:(distinct/groupBy)* {
const option = {};
options.forEach(val=>{
var key = Object.keys(val)[0];
switch(key){
case 'distinct':
distinct = val[key]; break;
option.distinct = val[key]; break;
case 'groupBy':
groupBy = val[key]; break;
option.groupBy = val[key]; break;
}
});
return {
api:'count',
data:{
from:table,
where:where,
distinct : distinct,
groupBy:groupBy
...option
}
}
}


selectQuery = SELECT _+ ("*"_+)? as: asQuery? aggr:aggregateQry? FROM _ table:tableName _* join:joinQry* _* where:whereQry? _*
option:(skip/limit/distinct/orderBy/groupBy)* {
var skip=null;
var limit=null;
var distinct = false;
var order = null;
var groupBy = null;
option.forEach(val=>{
options:(skip/limit/distinct/orderBy/groupBy)* {
const option = {};
options.forEach(val=>{
var key = Object.keys(val)[0];
switch(key){
case 'skip':
skip= val[key]; break;
option.skip= val[key]; break;
case 'limit':
limit= val[key]; break;
option.limit= val[key]; break;
case 'distinct':
distinct = val[key]; break;
option.distinct = val[key]; break;
case 'order':
order = val[key]; break;
option.order = val[key]; break;
case 'groupBy':
groupBy = val[key]; break;
option.groupBy = val[key]; break;
}
});
let modifiedWhere ;
Expand Down Expand Up @@ -291,11 +289,7 @@ option:(skip/limit/distinct/orderBy/groupBy)* {
data:{
from:table,
where:modifiedWhere,
skip:skip,
limit:limit,
distinct : distinct,
order:order,
groupBy:groupBy,
...option,
aggregate : aggr,
join:join.length===0?null:join
}
Expand Down Expand Up @@ -885,3 +879,5 @@ LEFT "left" = L E F T

AS "as" = A S

UPSERT "upsert" = U P S E R T

Loading

0 comments on commit 80b4dc4

Please sign in to comment.