Skip to content

Commit

Permalink
Reverse order of PARTITION and WHERE clauses (#39)
Browse files Browse the repository at this point in the history
Motivation
-------------
WHERE clause was being added before the PARTITION clause in cases where both were used, causing invalid N1QL to be generated.

Modifications
------------------
Moved the addition of the WHERE clause to be after the PARTITION clause (if any) is added.

Limit Node.js version to 8 in Travis
  • Loading branch information
dgrim-CE authored and brantburnett committed Jun 21, 2018
1 parent 85689f0 commit c9f8292
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: required
language: node_js
node_js:
- node
- "8"
services:
- docker
before_script:
Expand Down
10 changes: 6 additions & 4 deletions app/index-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,19 @@ export class IndexDefinition extends IndexDefinitionBase {
statement = `CREATE INDEX ${indexName}`;
statement += ` ON ${ensureEscaped(bucketName)}`;
statement += ` (${this.index_key.join(', ')})`;

if (this.condition) {
statement += ` WHERE ${this.condition}`;
}
}

if (this.partition) {
statement +=
` PARTITION BY ${this.getPartitionString()}`;
}

if (!this.is_primary) {
if (this.condition) {
statement += ` WHERE ${this.condition}`;
}
}

withClause = _.extend({}, withClause, {
defer_build: true,
});
Expand Down

0 comments on commit c9f8292

Please sign in to comment.