typeorm / typeorm

ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
http://typeorm.io
MIT License
34.14k stars 6.29k forks source link

Unable to use URL in ioredis cache options #7631

Closed JoeCap08055 closed 3 years ago

JoeCap08055 commented 3 years ago

Issue Description

According to the ioredis docs, the following connection options are equivalent within the cache {} block:

1.

cache {
   type: "ioredis",
   options {
      port: 1234,
      host: "myhost",
      db: 1
   }
}

2.

cache {
   type: "ioredis",
   port: 1234,
   options {
      host: "myhost",
      db: 1
   }
}

3.

cache {
   type: "ioredis",
   port: "redis://myhost:1234/1"
}

Expected Behavior

All three config options above produce the same result, which is an ioredis query cache connected to myhost on port 1234, database index 1

Actual Behavior

Option 1 succeeds. Option 2 ignores port and only uses the values inside the options block, using the ioredis default port 6379. Connection fails. Option 3 ignores port and attempts to connect to localhost:6379, and fails.

Steps to Reproduce

Try each of the listed cache configs in your ormconfig.js

My Environment

Dependency Version
Operating System
Node.js version v14.16.1
Typescript version v3.9.9
TypeORM version v0.2.32
ioredis version v4.27.2

Additional Context

Relevant Database Driver(s)

Are you willing to resolve this issue by submitting a Pull Request?

I've made a fix & tested locally. Just need guidance with the pull request.

JoeCap08055 commented 3 years ago

I have a pull request ready to submit, but I don't have permission to push my branch

Esqarrouth commented 2 years ago

Does this only work in ioredis? What about normal redis?