Skip to content

sort.split is not a function or its return value is not iterable #272

@danielbrutti

Description

@danielbrutti

Describe the bug
An exception occurs when trying to sort a list component by any column.

[Nest] 144701   - 04/17/2022, 11:39:54 AM   [ExceptionsHandler] sort.split is not a function or its return value is not iterable +27ms
TypeError: sort.split is not a function or its return value is not iterable
    at new Sort (/home/daniel/workspace/github/my-expense-nodejs/server/src/domain/base/pagination.entity.ts:11:52)
    at new PageRequest (/home/daniel/workspace/github/my-expense-nodejs/server/src/domain/base/pagination.entity.ts:35:28)
    at AccountRecordController.getAll (/home/daniel/workspace/github/my-expense-nodejs/server/src/web/rest/account-record.controller.ts:42:42)
    at /home/daniel/workspace/github/my-expense-nodejs/server/node_modules/@nestjs/core/router/router-execution-context.js:38:29
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

The sort variable does not contains a string, instead is an array with value [ 'date,asc', 'id' ]

Then the exception happens on the constructor:

constructor(sort: string) {
        if (sort) {
            [this.property, this.direction] = sort.split(',');
        }
    }

To Reproduce
Steps to reproduce the behavior:

  1. Create a new nhipster project
  2. Generate an entity
  3. Start the app and go to the entity list
  4. Try to sort by any column

Expected behavior
The sort should work and no exception be thrown.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Linux Mint 20
  • Browser Brave
  • Version 1.37.114

NHipster configuration

Welcome to the JHipster Information Sub-Generator

##### **JHipster Version(s)**

my-expenses@0.0.1-SNAPSHOT /home/daniel/workspace/github/my-expense-nodejs
├─┬ generator-jhipster-nodejs@2.0.0
│ └── generator-jhipster@7.0.1 deduped
└── generator-jhipster@7.0.1



##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**


<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "blueprints": [
      {
        "name": "generator-jhipster-nodejs",
        "version": "2.0.0"
      }
    ],
    "otherModules": [
      {
        "name": "generator-jhipster-nodejs",
        "version": "2.0.0"
      }
    ],
    "applicationType": "monolith",
    "baseName": "myExpenses",
    "jhipsterVersion": "7.0.1",
    "skipClient": false,
    "skipServer": false,
    "skipUserManagement": false,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "testFrameworks": [],
    "pages": [],
    "creationTimestamp": 1650074825191,
    "serverPort": "8081",
    "packageName": "com.jhipster.node",
    "databaseType": "sql",
    "devDatabaseType": "sqlite",
    "prodDatabaseType": "mysql",
    "authenticationType": "jwt",
    "clientFramework": "angularX",
    "withAdminUi": true,
    "clientTheme": "darkly",
    "clientThemeVariant": "primary",
    "enableTranslation": true,
    "nativeLanguage": "es",
    "packageFolder": "com/jhipster/node",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "serviceDiscoveryType": false,
    "websocket": false,
    "searchEngine": false,
    "messageBroker": false,
    "clientPackageManager": "npm",
    "languages": ["es"],
    "cacheProvider": "ehcache",
    "buildTool": "maven",
    "enableHibernateCache": true,
    "reactive": false,
    "entities": ["MoneyAccount", "Currency", "AccountRecord", "Category", "CategoryRule"],
    "lastLiquibaseTimestamp": 1650075132000
  }
}

</pre>
</details>


##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**

<details>
<summary>JDL entity definitions</summary>

<pre>
entity MoneyAccount {
  accountName String
  initialBalance BigDecimal
  accountType AccountType
}
entity Currency {
  currencyName String
  symbol String
  usdPrice BigDecimal
}
entity AccountRecord {
  date LocalDate
  amount BigDecimal
  type AccountRecordType
}
entity Category {
  categoryName String
  categoryType CategoryType
}
entity CategoryRule {
  match String
}
enum AccountType {
  TRANSACTIONAL,
  SAVINGS
}
enum AccountRecordType {
  INCOME,
  EXPENSE,
  DEPOSIT,
  WITHDRAW
}
enum CategoryType {
  INCOME,
  EXPENSE
}

relationship OneToOne {
  CategoryRule{category(categoryName)} to Category
}
relationship OneToMany {
  MoneyAccount{accountRecord} to AccountRecord{account(accountName)}
}
relationship ManyToOne {
  MoneyAccount{currency(currencyName)} to Currency
  AccountRecord{category(categoryName)} to Category
}

dto MoneyAccount, Currency, AccountRecord, Category, CategoryRule with mapstruct
paginate MoneyAccount, Currency, AccountRecord, Category, CategoryRule with infinite-scroll
service MoneyAccount, Currency, AccountRecord, Category, CategoryRule with serviceClass
filter MoneyAccount, Currency, AccountRecord, Category, CategoryRule

</pre>
</details>


##### **Environment and Tools**

openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment (build 11.0.14.1+1-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.14.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

git version 2.35.3

node: v16.14.2

npm: 8.5.0

Docker version 20.10.14, build a224086

docker-compose version 1.29.1, build c34c88b2


No change to package.json was detected. No package manager install will be executed.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions