Skip to content

Commit 6f17db0

Browse files
fixes issue with tableName when entityName has camelCase (#51)
* fixes #47 * fixes issue with migration scripts * fixes issue with sequnce name in entity
1 parent 048702c commit 6f17db0

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

generators/controller/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module.exports = class extends BaseGenerator {
4141
this.configOptions.basePath = this.options['base-path'];
4242
this.configOptions.entityName = this.options.entityName;
4343
this.configOptions.entityVarName = _.camelCase(this.options.entityName);
44-
this.configOptions.tableName = _.lowerCase(this.options.entityName)+'s';
44+
this.configOptions.tableName = _.snakeCase(this.options.entityName)+'s';
4545
this.configOptions.supportDatabaseSequences =
4646
this.configOptions.databaseType === 'h2'
4747
|| this.configOptions.databaseType === 'postgresql';

generators/controller/templates/app/src/main/java/entities/Entity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class <%= entityName %> {
2828
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "<%= entityVarName %>_id_generator")
2929
@SequenceGenerator(
3030
name = "<%= entityVarName %>_id_generator",
31-
sequenceName = "<%= entityVarName %>_id_seq",
31+
sequenceName = "<%= tableName %>_id_seq",
3232
allocationSize = 100)
3333
<%_ } _%>
3434
<%_ if (!supportDatabaseSequences) { _%>
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
create sequence <%= entityVarName %>_id_seq start with 1 increment by 100;
1+
create sequence <%= tableName %>_id_seq start with 1 increment by 100;
22

33
create table <%= tableName %> (
4-
id bigint DEFAULT nextval('<%= entityVarName %>_id_seq') not null,
4+
id bigint DEFAULT nextval('<%= tableName %>_id_seq') not null,
55
text varchar(1024) not null,
66
primary key (id)
77
);

generators/controller/templates/app/src/main/resources/db/migration/liquibase/changelog/01-new_table_with_seq.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
77
<changeSet author="sivalabs" id="createTable-<%= tableName %>">
88
<createSequence
9-
sequenceName="<%= entityVarName %>_id_seq"
9+
sequenceName="<%= tableName %>_id_seq"
1010
incrementBy="100"
1111
startValue="1"
1212
/>
1313
<createTable tableName="<%= tableName %>">
14-
<column name="id" type="bigint" defaultValueSequenceNext="<%= entityVarName %>_id_seq">
14+
<column name="id" type="bigint" defaultValueSequenceNext="<%= tableName %>_id_seq">
1515
<constraints primaryKey="true" nullable="false"/>
1616
</column>
1717
<column name="text" type="varchar(1024)">

0 commit comments

Comments
 (0)