Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ notifications:
node_js:
- 10
before_install:
- sudo apt-get update
- sudo apt-get install expect
- sudo apt-get install libnotify-bin
install:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

---

[![Build Status](https://travis-ci.org/bullhorn/taurus.svg?branch=master)](https://travis-ci.org/bullhorn/taurus)
[![Build Status](https://travis-ci.com/bullhorn/taurus.svg?branch=master)](https://travis-ci.com/bullhorn/taurus)
[![Dependency Status](https://dependencyci.com/github/bullhorn/taurus/badge)](https://dependencyci.com/github/bullhorn/taurus)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
[![npm version](https://badge.fury.io/js/%40bullhorn%2Ftaurus.svg)](https://badge.fury.io/js/%40bullhorn%2Ftaurus)
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h1 id="-taurus-taurus-banner-gif-https-bullhon-github-io-"><a href="https://bul
<p>The official client library for connecting to Bullhorn REST API</p>
</blockquote>
<hr>
<p><a href="https://travis-ci.org/bullhorn/taurus"><img src="https://travis-ci.org/bullhorn/taurus.svg?branch=master" alt="Build Status: Linux"></a> <a href="https://dependencyci.com/github/bullhorn/taurus"><img src="https://dependencyci.com/github/bullhorn/taurus/badge" alt="Dependency Status"></a> <a href="https://github.com/sindresorhus/xo"><img src="https://img.shields.io/badge/code_style-XO-5ed9c7.svg" alt="XO code style"></a>
<p><a href="https://travis-ci.com/bullhorn/taurus"><img src="https://travis-ci.com/bullhorn/taurus.svg?branch=master" alt="Build Status: Linux"></a> <a href="https://dependencyci.com/github/bullhorn/taurus"><img src="https://dependencyci.com/github/bullhorn/taurus/badge" alt="Dependency Status"></a> <a href="https://github.com/sindresorhus/xo"><img src="https://img.shields.io/badge/code_style-XO-5ed9c7.svg" alt="XO code style"></a>
<a href="https://badge.fury.io/js/%40bullhorn%2Ftaurus"><img src="https://badge.fury.io/js/%40bullhorn%2Ftaurus.svg" alt="npm version"></a></p>
<hr>
<p><a href="http://bullhorn.github.io">Website</a> • <a href="http://bullhorn.github.io">Docs</a> • <a href="https://medium.com/bullhorn-dev">Blog</a> </p>
Expand Down
4 changes: 4 additions & 0 deletions src/services/Where.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ export class Where {
const value = data[key];
if (key === 'or') {
queries.push(`(${Where.toQuerySyntax(value).replace(/ AND /g, ' OR ')})`);
} else if (key === 'groupedOr' && Array.isArray(value) && value.length > 0) {
queries.push(`(${value.map((group) => {
return `(${Where.toQuerySyntax(group)})`;
}).join(' OR ')})`);
} else if (key === 'orMinMax') {
for (const subkey of Object.keys(value)) {
queries.push(`(${Where.parseQueryValue(subkey, value[subkey])})`);
Expand Down
37 changes: 37 additions & 0 deletions test/Where.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,43 @@ describe('Where', () => {
});
});

describe('with groupedOr queries', () => {
it('should create a valid grouped OR query', () => {
const where = Where.toQuerySyntax({
title: 'Mr. President',
groupedOr: [{
firstName: 'Abe',
lastName: 'Lincoln',
}, {
owner: {
firstName: 'Abe',
lastName: 'Lincoln',
},
}]
});

expect(where).toEqual("title='Mr. President' AND ((firstName='Abe' AND lastName='Lincoln') OR (owner.firstName='Abe' AND owner.lastName='Lincoln'))");
});
it('should create a valid OR query with 3 or more grouped or conditions', () => {
const where = Where.toQuerySyntax({
groupedOr: [{
firstName: 'Abe',
lastName: 'Lincoln',
title: 'Mr. President',
}, {
owner: {
firstName: 'Abe',
lastName: 'Lincoln',
},
}, {
externalID: 'testID',
}]
});

expect(where).toEqual("((firstName='Abe' AND lastName='Lincoln' AND title='Mr. President') OR (owner.firstName='Abe' AND owner.lastName='Lincoln') OR (externalID='testID'))");
});
});

describe('with OR min/max queries', () => {
it('should create a valid nested OR min/max query', () => {
const where = Where.toQuerySyntax({
Expand Down