Repository: jeremydaly/dynamodb-toolbox (ts)

Issue:
Conditions error when lte or gte is zero
On an entity `update()`, when I use a `lte` or `gte` condition where the value is zero, I receive an error "A condition is required". I was also using `execute: false`, in case that helps.

In my particular case, I was able to work around this by changing the condition to a `between` call.

```javascript
// Fails
const inputParam = 0;
const conditions = { attr: 'myAttribute', lte: inputParam };
await MyEntity.update(someObject, { conditions, execute: false });
```
```javascript
// Succeeds
const inputParam = 0;
const conditions = { attr: 'myAttribute', between: [0, inputParam] };
await MyEntity.update(someObject, { conditions, execute: false });
```


Pull request description:
Allow 0 in comparaison operators
Closes #87 

Patch:
diff --git a/lib/expressionBuilder.js b/lib/expressionBuilder.js
index 00fb601a..73f0369d 100644
--- a/lib/expressionBuilder.js
+++ b/lib/expressionBuilder.js
@@ -130,10 +130,10 @@ const parseClause = (_clause,grp,table) => {
   if (eq !== undefined) { value = eq; f = 'eq'; operator = '=' }
   if (ne !== undefined) { value = value ? conditionError(f) : ne; f = 'ne'; operator = '<>' }
   if (_in) { value = value ? conditionError(f) : _in; f = 'in'; operator = 'IN' }
-  if (lt) { value = value ? conditionError(f) : lt; f = 'lt'; operator = '<' }
-  if (lte) { value = value ? conditionError(f) : lte; f = 'lte'; operator = '<=' }
-  if (gt) { value = value ? conditionError(f) : gt; f = 'gt'; operator = '>' }
-  if (gte) { value = value ? conditionError(f) : gte; f = 'gte';  operator = '>=' }
+  if (lt !== undefined) { value = value ? conditionError(f) : lt; f = 'lt'; operator = '<' }
+  if (lte !== undefined) { value = value ? conditionError(f) : lte; f = 'lte'; operator = '<=' }
+  if (gt !== undefined) { value = value ? conditionError(f) : gt; f = 'gt'; operator = '>' }
+  if (gte !== undefined) { value = value ? conditionError(f) : gte; f = 'gte';  operator = '>=' }
   if (between) { value = value ? conditionError(f) : between; f = 'between'; operator = 'BETWEEN' }
   if (exists !== undefined) { value = value ? conditionError(f) : exists; f = 'exists'; operator = 'EXISTS' }
   if (contains) { value = value ? conditionError(f) : contains; f = 'contains'; operator = 'CONTAINS' }


Test patch:
diff --git a/__tests__/expressionBuilder.unit.test.js b/__tests__/expressionBuilder.unit.test.js
index d138d776..1b8b25fb 100644
--- a/__tests__/expressionBuilder.unit.test.js
+++ b/__tests__/expressionBuilder.unit.test.js
@@ -342,4 +342,15 @@ describe('expressionBuilder',() => {
       .toThrow(`A condition is required`)
   })
 
+  it('allows 0 in comparaison expression', () => {
+    expect(() => expressionBuilder({ attr: 'a', lte: 0 },TestTable,'TestEntity'))
+      .not.toThrow(`A condition is required`)
+    expect(() => expressionBuilder({ attr: 'a', lt: 0 },TestTable,'TestEntity'))
+      .not.toThrow(`A condition is required`)
+    expect(() => expressionBuilder({ attr: 'a', gte: 0 },TestTable,'TestEntity'))
+      .not.toThrow(`A condition is required`)
+    expect(() => expressionBuilder({ attr: 'a', gt: 0 },TestTable,'TestEntity'))
+      .not.toThrow(`A condition is required`)
+  })
+
 })