Description
Description
When using the pg-connection-string package to parse PostgreSQL connection URLs with query parameters, the parser does not create an options property containing the query string. Instead, it adds each query parameter directly to the returned config object.
This breaks compatibility with code that expects the parser to return query parameters in an options property, which seems to be a common expectation based on other PostgreSQL connection string parsers.
Example
const { parse } = require('pg-connection-string');
const url = "postgresql://admin:password@example.com:5432/mydb?schema=public&ssl=true";
const config = parse(url);
console.log(config);
// Current output:
// {
// schema: 'public',
// ssl: 'true',
// user: 'admin',
// password: 'password',
// host: 'example.com',
// port: '5432',
// database: 'mydb'
// }
// Expected output would include an options property:
// {
// user: 'admin',
// password: 'password',
// host: 'example.com',
// port: '5432',
// database: 'mydb',
// schema: 'public',
// ssl: 'true',
// options: 'schema=public&ssl=true'
// }
Impact
This causes issues in code that expects to find query parameters in config.options for reconstructing connection strings. For example, when implementing SSH tunneling for PostgreSQL connections, it's common to need to preserve all query parameters when creating the tunneled connection URL.
Suggested Fix
The parser could be modified to collect the original query parameters string and include it as an options property in the returned configuration object, while still preserving the individual parameters as direct properties.RetryClaude can make mistakes. Please double-check responses.