Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@synatic/noql

Package Overview
Dependencies
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@synatic/noql - npm Package Compare versions

Comparing version 2.1.17 to 2.1.18

22

lib/make/groupByColumnParser.js

@@ -40,2 +40,5 @@ const _allowableFunctions = require('../MongoFunctions');

// todo there are more
const expressionNamesToExcludeFromId = ['count', 'sum', 'min', 'max'];
const expressionsToExpand = [{name: 'round', expressionKey: '$round'}];
/**

@@ -84,3 +87,4 @@ * @param {import('../types').Column} column The column to parse

);
if (column.expr.name.toLowerCase() === 'count') {
const lowerColumnName = column.expr.name.toLowerCase();
if (expressionNamesToExcludeFromId.indexOf(lowerColumnName) >= 0) {
result.groupBy.$group[column.as] = parsedExpr;

@@ -93,2 +97,18 @@ return; // count values can't go in the groupBy

}
const expand = expressionsToExpand.find(
(e) => e.name === lowerColumnName
);
if (expand) {
const [colExpression, precision] = parsedExpr[expand.expressionKey];
if (typeof colExpression !== 'string') {
result.groupBy.$group[column.as] = colExpression;
result.groupByProject = result.groupByProject || {};
result.groupByProject[column.as] = {
[expand.expressionKey]: precision
? [`$${column.as}`, precision]
: [`$${column.as}`],
};
return;
}
}
result.groupBy.$group._id[column.as] = parsedExpr;

@@ -95,0 +115,0 @@ return;

5

lib/make/makeAggregatePipeline.js

@@ -324,3 +324,6 @@ const groupByColumnParserModule = require('./groupByColumnParser');

groupByProject[k] = 0;
} else if (!k.startsWith('_tempAggregateCol_')) {
} else if (
!k.startsWith('_tempAggregateCol_') &&
!$check.assigned(groupByProject[k])
) {
groupByProject[k] = `$${k}`;

@@ -327,0 +330,0 @@ }

@@ -81,4 +81,3 @@ const getParsedValueFromBinaryExpressionModule = require('./getParsedValueFromBinaryExpression');

function makeArg(expr, depth, context) {
// todo check all these types
if (expr.type === 'function') {
if (expr.type === 'function' || expr.type === 'aggr_func') {
return makeProjectionExpressionPart(expr, context, depth);

@@ -85,0 +84,0 @@ }

{
"name": "@synatic/noql",
"version": "2.1.17",
"version": "2.1.18",
"description": "Convert SQL statements to mongo queries or aggregates",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc