New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@altangent/graphql-filter-mysql

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@altangent/graphql-filter-mysql - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

2

package.json
{
"name": "@altangent/graphql-filter-mysql",
"version": "1.3.0",
"version": "1.4.0",
"description": "Graphql filtering exection to generate mysql query syntax",

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

@@ -5,4 +5,21 @@ let mysqlClient = require('mysql');

buildWhere,
properties,
};
function properties(rootFilter) {
let keys = Object.keys(rootFilter);
let props = {};
for (let key of keys) {
if (key === '_and' || key === '_or') {
for (let subquery of rootFilter[key]) {
props = { ...props, ...properties(subquery) };
}
}
else {
props[key] = true;
}
}
return props;
}
function buildWhere(rootFilter, columnMap) {

@@ -9,0 +26,0 @@ let result = ' and ';

const { expect } = require('chai');
const { buildWhere } = require('./filter-map');
const { buildWhere, properties } = require('./filter-map');

@@ -123,1 +123,68 @@ describe('.buildQuery', () => {

});
describe('.properties', () => {
let assess = [
{
desc: 'should return single property',
input: { currencyName: { _eq: 'bitcoin' } },
expected: { currencyName: true },
},
{
desc: 'should return multiply properties',
input: { currencyName: { _eq: 'bitcoin' }, currencySymbol: { _like: '*bit*' } },
expected: { currencyName: true, currencySymbol: true },
},
{
desc: 'should return anded object at root',
input: {
_and: [{ currencyName: { _eq: 'bitcoin' } }, { currencySymbol: { _like: '*bit*' } }],
},
expected: { currencyName: true, currencySymbol: true },
},
{
desc: 'should return ored object at root',
input: {
_or: [{ currencyName: { _eq: 'bitcoin' } }, { currencySymbol: { _like: '*bit*' } }],
},
expected: { currencyName: true, currencySymbol: true },
},
{
desc: 'should return nested anded object',
input: {
currencySupply: { _eq: 1 },
_and: [{ currencyName: { _eq: 'bitcoin' } }, { currencySymbol: { _like: '*bit*' } }],
},
expected: { currencySupply: true, currencyName: true, currencySymbol: true },
},
{
desc: 'should return nested ored object',
input: {
currencySupply: { _eq: 1 },
_or: [{ currencyName: { _eq: 'bitcoin' } }, { currencySymbol: { _like: '*bit*' } }],
},
expected: { currencySupply: true, currencyName: true, currencySymbol: true },
},
{
desc: 'should return combined anded and ored',
input: {
_and: [{ currencyName: { _eq: 'bitcoin' } }, { currencySymbol: { _like: '*bit*' } }],
_or: [{ currencyName: { _eq: 'bitcoin' } }, { currencySupply: { _eq: 1 } }],
},
expected: { currencySupply: true, currencyName: true, currencySymbol: true },
},
{
desc: 'should have single entry for dupes',
input: {
_and: [{ currencyName: { _eq: 'bitcoin' } }, { currencySymbol: { _like: '*bit*' } }],
_or: [{ currencyName: { _eq: 'bitcoin' } }, { currencyName: { _eq: 'litecoin' } }],
},
expected: { currencyName: true, currencySymbol: true },
},
];
for (let ass of assess) {
it(ass.desc, () => {
expect(properties(ass.input)).to.deep.equal(ass.expected);
});
}
});
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