sails: sails-postgres doesn't work with unix socket connections

DB adapter & version: sails-postgres@

Unless I’m missing something obvious, sails-postgres won’t work with PostgreSQL unix socket connections.

This seems to be a direct result of the conversion from separate datastore config values to a connectionString performed in sails-postgresql/helpers/register-data-store.js.

I will look into this further and hopefully provide a patch shortly.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 25 (3 by maintainers)

Commits related to this issue

Most upvoted comments

one year later still open?

two years now 😃

For the brave and desperate:

const fs = require('fs');

function patchAndReplace(path, replacements) {
  let text = fs.readFileSync(path, { encoding:'utf-8' });
  replacements.forEach(r => {
    text = text.replace(r.find, r.replace);
  });
  fs.writeFileSync(path, text, 'utf-8');
}

patchAndReplace('node_modules/sails-postgresql/helpers/register-data-store.js', [
  {
    find:    "if (!_.has(inputs.config, 'url')) {",
    replace: "if (false && !_.has(inputs.config, 'url')) {",
  },
]);

patchAndReplace('node_modules/machinepack-postgresql/machines/create-manager.js', [
  {
    find:    'required: true',
    replace: '//required: true',
  },
  {
    find:    "// Remember: connection string takes priority over `meta` in the event of a conflict.",
    replace: "if(inputs.connectionString !== undefined)",
  },
]);

I’ll try to wrap this in a couple of PRs soonish.