@synatic/sql-to-mongo
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -144,11 +144,5 @@ const getParsedValueFromBinaryExpressionModule = require('./getParsedValueFromBinaryExpression'); | ||
} | ||
if (column.expr.type && column.as) { | ||
if (column.as === '$$ROOT') { | ||
result.replaceRoot = { | ||
$replaceRoot: {newRoot: `$${column.expr.value}`}, | ||
}; | ||
return; | ||
} | ||
result.parsedProject.$project[column.as] = { | ||
$literal: column.expr.value, | ||
if (column.as && column.as === '$$ROOT') { | ||
result.replaceRoot = { | ||
$replaceRoot: {newRoot: `$${column.expr.value}`}, | ||
}; | ||
@@ -158,16 +152,26 @@ return; | ||
if ( | ||
(column.expr.type === 'double_quote_string' || | ||
column.expr.type === 'string') && | ||
!column.as | ||
column.expr.type === 'double_quote_string' || | ||
column.expr.type === 'string' || | ||
column.expr.type === 'single_quote_string' | ||
) { | ||
const parts = column.expr.value.split('.'); | ||
if (!column.as) { | ||
if (parts.length !== 2) { | ||
throw new Error( | ||
`Require as for calculation or <table>.<column>:${ | ||
column.expr.name || column.expr.value | ||
}` | ||
); | ||
} | ||
const colName = parts[1]; | ||
result.parsedProject.$project[colName] = `$${column.expr.value}`; | ||
return; | ||
} | ||
if (parts.length !== 2) { | ||
throw new Error( | ||
`Require as for calculation or <table>.<column>:${ | ||
column.expr.name || column.expr.value | ||
}` | ||
); | ||
result.parsedProject.$project[column.as] = { | ||
$literal: column.expr.value, | ||
}; | ||
return; | ||
} | ||
const colName = parts[1]; | ||
result.parsedProject.$project[colName] = `$${column.expr.value}`; | ||
result.parsedProject.$project[column.as] = `$${column.expr.value}`; | ||
return; | ||
@@ -174,0 +178,0 @@ } |
{ | ||
"name": "@synatic/sql-to-mongo", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Convert SQL to mongo queries or aggregates", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
199241
4116