Add default fallback_application_name
How about adding a default value for fallback_application_name to show case the driver being used in the wild?
Some possible values:
Node.JS PostgreSQL DriverNode.JS PostgreSQL Driver - pgNode.JS PostgreSQL Driver - [email protected]
I like the last one as having the driver version number may also be useful for a DBA debugging via pg_stat_activity.
For comparison, the PostgreSQL JDBC (Java) driver defaults to "PostgreSQL Java Driver": https://github.com/pgjdbc/pgjdbc/blob/d0453b7582975438eb889082cffcfd8ebe6e3e4d/pgjdbc/src/main/java/org/postgresql/PGProperty.java#L318
If there's interest I can put together a patch for this. The defaults are already in one place so it's just a matter of changing fallback_application_name and updating a couple tests that expect the default name to be empty.
Thoughts?
const { Pool } = require('pg');
const packageVersion = require('pg/package.json').version; // Import version from package.json
const pool = new Pool({
// ... other connection parameters ...
application_name: `Node.JS PostgreSQL Driver - pg@${packageVersion}` // Set default application name
});
pool.query('SELECT NOW()', (err, res) => {
// Your query logic here
pool.end();
});