Skip to content

Commit

Permalink
fix #129
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelo Manganiello committed Aug 21, 2020
1 parent 90ad63f commit 3bd61dc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

# [1.2.0](https://github.com/jhipster/generator-jhipster-nodejs/tree/v1.2.0)

- Blob types not saved [issue #129](https://github.com/jhipster/generator-jhipster-nodejs/issues/129)
- Unexpected logs when creating a new app using import-jdl [issue #159](https://github.com/jhipster/generator-jhipster-nodejs/issues/159)
- Language i18n for angular home page translation NHipster [issue #45](https://github.com/jhipster/generator-jhipster-nodejs/issues/45)
- Language i18n for react home page translation NHipster [issue #59](https://github.com/jhipster/generator-jhipster-nodejs/issues/59)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ export default class <%= asEntity(entityClass) %> extends BaseEntity {
<%_ if (fields[idx].fieldIsEnum) { _%>
@Column({type: 'simple-enum', name: '<%-fieldNameAsDatabaseColumn %>', enum: <%= fieldType %>})
<%_ } else if (['Instant', 'ZonedDateTime', 'LocalDate'].includes(fieldType)) { _%>
@Column({<%_ if(fieldColumnType) { _%> type: '<%-fieldColumnType%>' ,<%_ }_%> name: "<%-fieldNameAsDatabaseColumn %>"<% if (required) { %>, nullable: false<% } %><% if (unique) { %>, unique: true<% } %>})
@Column({<%_ if(fieldColumnType) { _%> type: '<%-fieldColumnType%>' ,<%_ }_%> name: "<%-fieldNameAsDatabaseColumn %>"<% if (!required) { %>, nullable: true<% } %><% if (unique) { %>, unique: true<% } %>})
<%_ } else if (fieldType === 'BigDecimal') { _%>
@Column({<%_ if(fieldColumnType) { _%> type: '<%-fieldColumnType%>' ,<%_ }_%> name: "<%-fieldNameAsDatabaseColumn %>", precision : 10, scale : 2<% if (required) { %>, nullable: false<% } %><% if (unique) { %>, unique: true<% } %>})
@Column({<%_ if(fieldColumnType) { _%> type: '<%-fieldColumnType%>' ,<%_ }_%> name: "<%-fieldNameAsDatabaseColumn %>", precision : 10, scale : 2<% if (!required) { %>, nullable: true<% } %><% if (unique) { %>, unique: true<% } %>})
<%_ } else { _%>
@Column({<%_ if(fieldColumnType) { _%> type: '<%-fieldColumnType%>' ,<%_ }_%> name: "<%-fieldNameAsDatabaseColumn %>"<% if (fieldValidate === true) { %><% if (fieldValidateRules.includes('maxlength')) { %>, length: <%= fieldValidateRulesMaxlength %><% } %><% if (required) { %>, nullable: false<% } %><% if (unique) { %>, unique: true<% } %><% } %>})
@Column({<%_ if(fieldColumnType) { _%> type: '<%-fieldColumnType%>' ,<%_ }_%> name: "<%-fieldNameAsDatabaseColumn %>"<% if (fieldValidate === true) { %><% if (fieldValidateRules.includes('maxlength')) { %>, length: <%= fieldValidateRulesMaxlength %><% } %> <% } %><% if (!required) { %>, nullable: true<% } %><% if (unique) { %>, unique: true<% }%>})
<%_ } _%>
<%_ if (fields[idx].fieldIsEnum) { _%>
<%= fieldName %>: <%= fieldType %>;
Expand All @@ -80,7 +80,7 @@ export default class <%= asEntity(entityClass) %> extends BaseEntity {
<%_ } _%>
<%_ if ((fieldType === 'byte[]' || fieldType === 'ByteBuffer') && fieldTypeBlobContent !== 'text') { _%>
@Column({name: '<%-fieldNameAsDatabaseColumn %>_content_type'})
@Column({name: '<%-fieldNameAsDatabaseColumn %>_content_type'<% if (!required) { %>, nullable: true<% } %>})
<%= fieldName %>ContentType: string;
<%_ }
} _%>
Expand Down
30 changes: 15 additions & 15 deletions test/entity.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,67 +91,67 @@ describe('Subgenerator entity of nodejs JHipster blueprint', () => {
assert.fileContent(greatEntityPath, "import { Gender } from './enumeration/gender';");

// name UUID unique field
assert.fileContent(greatEntityPath, "@Column({ name: 'name', unique: true })");
assert.fileContent(greatEntityPath, "@Column({ name: 'name', nullable: true, unique: true })");
assert.fileContent(greatEntityPath, 'name: string;');

// Gender enum field
assert.fileContent(greatEntityPath, "@Column({ type: 'simple-enum', name: 'gender', enum: Gender })");
assert.fileContent(greatEntityPath, 'gender: Gender;');

// address String required field
assert.fileContent(greatEntityPath, "@Column({ name: 'address', nullable: false })");
assert.fileContent(greatEntityPath, "@Column({ name: 'address' })");
assert.fileContent(greatEntityPath, 'address: string;');

// istrue Boolean required field
assert.fileContent(greatEntityPath, "@Column({ type: 'boolean', name: 'istrue' })");
assert.fileContent(greatEntityPath, "@Column({ type: 'boolean', nullable: true, name: 'istrue' })");
assert.fileContent(greatEntityPath, 'istrue: boolean;');

// borndate LocalDate required field
assert.fileContent(greatEntityPath, "@Column({ type: 'date', name: 'borndate', nullable: false })");
assert.fileContent(greatEntityPath, "@Column({ type: 'date', name: 'borndate' })");
assert.fileContent(greatEntityPath, 'borndate: any;');

// profileimage Blob field
assert.fileContent(greatEntityPath, "@Column({ type: 'blob', name: 'profileimage' })");
assert.fileContent(greatEntityPath, "@Column({ type: 'blob', name: 'profileimage', nullable: true })");
assert.fileContent(greatEntityPath, 'profileimage: any;');

// storage AnyBlob field
assert.fileContent(greatEntityPath, "@Column({ type: 'blob', name: 'storage' })");
assert.fileContent(greatEntityPath, "@Column({ type: 'blob', name: 'storage', nullable: true })");
assert.fileContent(greatEntityPath, 'storage: any;');

// datafile TextBlob field
assert.fileContent(greatEntityPath, "@Column({ type: 'blob', name: 'datafile' })");
assert.fileContent(greatEntityPath, "@Column({ type: 'blob', name: 'datafile', nullable: true })");
assert.fileContent(greatEntityPath, 'datafile: any;');

// image Blob field
assert.fileContent(greatEntityPath, "@Column({ type: 'blob', name: 'image' })");
assert.fileContent(greatEntityPath, "@Column({ type: 'blob', name: 'image', nullable: true })");
assert.fileContent(greatEntityPath, 'image: any;');

// amount BigDecimal field
assert.fileContent(greatEntityPath, "@Column({ type: 'decimal', name: 'amount', precision: 10, scale: 2 })");
assert.fileContent(greatEntityPath, "@Column({ type: 'decimal', name: 'amount', precision: 10, scale: 2, nullable: true })");
assert.fileContent(greatEntityPath, 'amount: number;');

// cfu Integer field
assert.fileContent(greatEntityPath, "@Column({ type: 'integer', name: 'cfu' })");
assert.fileContent(greatEntityPath, "@Column({ type: 'integer', name: 'cfu', nullable: true })");
assert.fileContent(greatEntityPath, 'cfu: number;');

// mynumber Double field
assert.fileContent(greatEntityPath, "@Column({ type: 'double', name: 'mynumber' })");
assert.fileContent(greatEntityPath, "@Column({ type: 'double', name: 'mynumber', nullable: true })");
assert.fileContent(greatEntityPath, 'mynumber: number;');

// count Long field
assert.fileContent(greatEntityPath, "@Column({ type: 'long', name: 'count' })");
assert.fileContent(greatEntityPath, "@Column({ type: 'long', name: 'count', nullable: true })");
assert.fileContent(greatEntityPath, 'count: number;');

// cent Float field
assert.fileContent(greatEntityPath, "@Column({ type: 'float', name: 'cent' })");
assert.fileContent(greatEntityPath, "@Column({ type: 'float', name: 'cent', nullable: true })");
assert.fileContent(greatEntityPath, 'cent: number;');

// creationtime Instant field
assert.fileContent(greatEntityPath, "@Column({ type: 'timestamp', name: 'creationtime' })");
assert.fileContent(greatEntityPath, "@Column({ type: 'timestamp', name: 'creationtime', nullable: true })");
assert.fileContent(greatEntityPath, 'creationtime: any;');

// deathtime ZonedDateTime field
assert.fileContent(greatEntityPath, "@Column({ type: 'datetime', name: 'deathtime' })");
assert.fileContent(greatEntityPath, "@Column({ type: 'datetime', name: 'deathtime', nullable: true })");
assert.fileContent(greatEntityPath, 'deathtime: any;');
});
});
Expand Down

0 comments on commit 3bd61dc

Please sign in to comment.