Skip to content

Allow postgres version to be set statically #11372

Closed

Description

@hfhchan-plb

Feature Description

Both database and searchSchema are only set in connect() when they are not defined, but queryRunner.getVersion() is always called.

Can the call to getVersion() also be changed to be similar to the other properties?

As this field is only used to determine if generated columns are supported, it can be trivially overwritten to reduce cold start time.

The Solution

This allows consumers of this library to set the version to avoid one extra query, which will reduce cold start time which is critical in serverless applications.

Considered Alternatives

N/A

Additional Context

No response

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

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

Yes, I have the time, and I know how to start.

Activity

  1. mguida22 commented on Apr 2, 2025

    @mguida22
    Collaborator

    I like the idea, it seems like something we would want to expose and document as an option and support across all drivers.

    Allowing users to set the database version and not looking it up also gives people an escape hatch if our version lookup doesn't work properly on their specific database type. For example, using a Postgres compatible db with the Postgres driver.

    @alumni what do you think?

  2. jovanadjuric commented on Apr 5, 2025

    @jovanadjuric
    Contributor

    I agree with @mguida22. We should also cover MySQL and SAP drivers, as they also use the version property.

    The TSDoc comments would need to be updated as well because the current description -Requires a SQL query to the DB, so it is not always set- would no longer be accurate.

  3. alumni commented on Apr 6, 2025

    @alumni
    Collaborator

    We rely on the driver version in a quite some places, so PR #11373 will break the behavior that relies on that.

    In #11376 (comment) I was suggesting to have some sort of lazy loading for the version. I think this is the only way to avoid loading the version on connect.

  4. pkuczynski commented on Nov 24, 2025

    @pkuczynski
    Member

    We rely on the driver version in a quite some places, so PR #11373 will break the behavior that relies on that.

    #11373 cant break anything as we already set the version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions