Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JHipster primary key type #230

Closed
glutengo opened this issue May 28, 2021 · 2 comments · Fixed by #231
Closed

Support JHipster primary key type #230

glutengo opened this issue May 28, 2021 · 2 comments · Fixed by #231
Assignees
Labels
Feature New feature v2.0.0 Stable version with jhipster 7.0.0
Milestone

Comments

@glutengo
Copy link
Contributor

Describe the bug
The problem is, that the frontend (and maybe some other places too) respect the pkType setting whilst for the NestJS Backend, this configuration option is ignored. The type is hardcoded in base.entity.ts (among others). As the default value for pkType seems to be number for databases like MySQL (see https://github.com/jhipster/generator-jhipster/blob/f12952fc9e0bcfa77052d315ee7968b49b1f3442/generators/generator-base-private.js#L1240) , the problem is effective without setting an explicit value for the configuration option.

The consequence of this problem is that the frontend expects the ids to be numbers while they are actually strings. This can have implications on the generated app and is likely to cause typing problems when comparing, filtering, sorting, etc.

To Reproduce
Steps to reproduce the behavior:

  1. Generate a new app via nhipster
  2. Select the default option for every question
  3. Compare server/src/domain/base/base.entity.ts (server) and src/main/webapp/app/entities/user/user.model.ts

Expected behavior
Type of the id property matches in both files

Actual behavior
Type of id property in base.entity.ts: string
Type of id property in user.model.ts: number

Desktop (please complete the following information):

  • OS: iOS 11.3
  • NHipster Version: 2.0.0-beta.1

NHipster configuration

.yo-rc.json
{
  "generator-jhipster": {
    "blueprints": [
      {
        "name": "generator-jhipster-nodejs",
        "version": "2.0.0-beta.1"
      }
    ],
    "otherModules": [
      {
        "name": "generator-jhipster-nodejs",
        "version": "2.0.0-beta.1"
      }
    ],
    "applicationType": "monolith",
    "baseName": "jhipster",
    "jhipsterVersion": "7.0.0",
    "skipClient": false,
    "skipServer": false,
    "skipUserManagement": false,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "testFrameworks": [],
    "pages": [],
    "creationTimestamp": 1622190455015,
    "serverPort": "8081",
    "packageName": "com.jhipster.node",
    "databaseType": "sql",
    "devDatabaseType": "sqlite",
    "prodDatabaseType": "mysql",
    "authenticationType": "jwt",
    "clientFramework": "angularX",
    "withAdminUi": true,
    "clientTheme": "none",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "packageFolder": "com/jhipster/node",
    "jwtSecretKey": "YTcyZjczMzQ0YzYzMmYwNjdkZDc5ZDFjYTNjZTIyNDI2NTVhNjRkODQ0YTRjZmJmN2EzOWJlNDAyYTJiMDBkN2Y0NTc0ZjNkOWQ2YzhkNjU5NGYwOTM1ODZiM2M3Njk4ZTMwMGI3MjliNzY2N2VjYmQ4NDMyNjI4MTYzOTIxN2I=",
    "serviceDiscoveryType": false,
    "websocket": false,
    "searchEngine": false,
    "messageBroker": false,
    "clientPackageManager": "npm",
    "clientThemeVariant": "",
    "languages": ["en"],
    "cacheProvider": "ehcache",
    "buildTool": "maven",
    "enableHibernateCache": true,
    "reactive": false
  }
}

Additional context
I discovered the problem while working on #214

I have prepared a branch to fix this which I will link as a PR soon.

glutengo pushed a commit to glutengo/generator-jhipster-nodejs that referenced this issue May 28, 2021
- Use getPkType(databaseType) instead of hardcoded type in NestJS backend
- Bump prettier version for optional chaining support
@ghost ghost linked a pull request May 28, 2021 that will close this issue
@ghost
Copy link

ghost commented May 28, 2021

Thanks for the contributing!
So, I defined the pkType as string and not customizable for nestjs simple use cases, it does not use, for example, the filter features. Besides this generator has been created from a old jhipster 6.x version.

Therefore, I am very happy for your PR!

@ghost ghost added the Feature New feature label May 28, 2021
@ghost ghost added this to the 2.0.0 milestone May 28, 2021
@ghost ghost added the v2.0.0 Stable version with jhipster 7.0.0 label May 28, 2021
@ghost ghost changed the title JHipster primary key type is ignored Support JHipster primary key type May 28, 2021
@ghost ghost closed this as completed in #231 May 28, 2021
ghost pushed a commit that referenced this issue May 28, 2021
Fix bug regarding pkType refs #230
@ghost
Copy link

ghost commented May 28, 2021

Well done! Thanks for the contribution!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature v2.0.0 Stable version with jhipster 7.0.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant