Skip to content
This repository has been archived by the owner on Mar 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request #117 from jhipster/fix-116
Browse files Browse the repository at this point in the history
Pagination is now forbidden when having a cassandra app
  • Loading branch information
MathieuAA authored Apr 23, 2017
2 parents 8f8722f + 43e0e8a commit 5751743
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/exceptions/exception_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const EXCEPTIONS = {
IllegalArgument: null,
IllegalAssociation: null,
IllegalName: null,
IllegalOption: null,
InvalidObject: null,
MalformedAssociation: null,
NoSQLModeling: null,
Expand Down
13 changes: 9 additions & 4 deletions lib/parser/jdl_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const _ = require('lodash'),
UnaryOptions = require('../core/jhipster/unary_options'),
BinaryOptions = require('../core/jhipster/binary_options'),
FieldTypes = require('../core/jhipster/field_types'),
DatabaseTypes = require('../core/jhipster/database_types'),
formatComment = require('../utils/format_utils').formatComment,
isReservedClassName = require('../core/jhipster/reserved_keywords').isReservedClassName,
isReservedFieldName = require('../core/jhipster/reserved_keywords').isReservedFieldName,
Expand Down Expand Up @@ -38,7 +39,7 @@ function parse(passedDocument, passedDatabaseType) {
fillEnums();
fillClassesAndFields(passedDatabaseType);
fillAssociations();
fillOptions();
fillOptions(passedDatabaseType);
return jdlObject;
}

Expand Down Expand Up @@ -187,9 +188,9 @@ function checkEntityDeclaration(relationship) {
}
}

function fillOptions() {
function fillOptions(passedDatabaseType) {
fillUnaryOptions();
fillBinaryOptions();
fillBinaryOptions(passedDatabaseType);
}

function fillUnaryOptions() {
Expand Down Expand Up @@ -231,9 +232,13 @@ function addOption(key, value) {
jdlObject.addOption(option);
}

function fillBinaryOptions() {
function fillBinaryOptions(passedDatabaseType) {
_.forEach(BinaryOptions.BINARY_OPTIONS, (optionValue) => {
_.forEach(document[optionValue], (documentOptionValue, documentOptionKey) => {
if (optionValue === BinaryOptions.BINARY_OPTIONS.PAGINATION
&& passedDatabaseType === DatabaseTypes.Types.cassandra) {
throw new buildException(exceptions.IllegalOption, "Pagination isn't allowed when the app uses Cassandra.");
}
addOption(optionValue, documentOptionKey);
});
});
Expand Down
10 changes: 10 additions & 0 deletions test/spec/parser/jdl_parser_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,16 @@ describe('JDLParser', () => {
});
});
});
describe('when having a cassandra app with paginated entities', () => {
const input = parseFromFiles(['./test/test_files/cassandra_jdl.jdl']);
it('fails', () => {
try {
JDLParser.parse(input, 'cassandra');
} catch (error) {
expect(error.name).to.eq('IllegalOptionException');
}
});
});
});
});
});

0 comments on commit 5751743

Please sign in to comment.