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

PostgresRecordManager requires postgresConnectionOptions even when passing a pool #7579

Closed
5 tasks done
JonathanVelkeneers opened this issue Jan 24, 2025 · 1 comment · Fixed by #7580
Closed
5 tasks done
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@JonathanVelkeneers
Copy link
Contributor

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

... in place for brevity

import ...

const embeddings = new AzureOpenAIEmbeddings();
const pool = new Pool(...);
const config = {
  pool: this.getPool(),
  columns: { ... },
};

// This works
const vectorStore = PGVectorStore.initialize(embeddings, {
  ...config,
  tableName: "table",
});

//This needs to be passed an empty postgresConnectionOptions
const recordManager = new PostgresRecordManager('upsert_documents', {
  ...this.config,
  tableName: "upsert_documents",
  postgresConnectionOptions: {},
});

Error Message and Stack Trace (if applicable)

No response

Description

postgresConnectionOptions needs to be made optional, and a check has to be implemented to check if either one of postgresConnectionOptions or pool is set.

This is done correctly in PGVectorStore

System Info

"pg": "8.13.0",
"@langchain/community": "0.3.3",
"langchain": "0.3.3"

Copy link

dosubot bot commented Jan 24, 2025

I found a similar unsolved discussion titled "Allow to pass an instance of Pool when instantiating PostgresRecordManager" which might be relevant to your issue [1].

Regarding your concern, the PostgresRecordManager currently requires postgresConnectionOptions even when a pool is provided. The PostgresRecordManagerOptions type enforces postgresConnectionOptions as a required field, which is why you need to pass an empty object if you are using a pool [2].

The intended behavior is to use the provided pool if it exists; otherwise, it creates a new pool using postgresConnectionOptions. This means that if a pool is provided, it takes precedence over postgresConnectionOptions [2].

To address this, you might consider suggesting a change to make postgresConnectionOptions optional when a pool is provided, similar to how it is handled in PGVectorStore [3].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
1 participant