sigil
sigil

Reputation: 9546

Sequelize.query() promise never resolves

I am trying to run a Sequelize query against a Postgres DB, as follows:

async getRowFromWorkerTable(contact_uri){
    console.log(`running query...`);
    let result;
    try{
        result = await sequelize.query("select * from worker where contact_uri='"+contact_uri+"'",
        { type: sequelize.QueryTypes.SELECT});
    }
    catch(err){
        console.err(err);
    }
    finally{
        console.log(`query complete.`);
    }
    return result;
}

I get the running query... text, but then no error or query complete.

I initialize sequelize prior to this as follows:

const sequelize=new Sequelize(process.env.database,process.env.username,process.env.password,{
    dialect:'postgres',
});

Examining the sequelize object with console.log({sequelize}) gives the following:

{
  sequelize: <ref *1> Sequelize {
    options: {
      dialect: 'postgres',
      dialectModule: null,
      dialectModulePath: null,
      host: 'localhost',
      protocol: 'tcp',
      define: {},
      query: {},
      sync: {},
      timezone: '+00:00',
      clientMinMessages: 'warning',
      standardConformingStrings: true,
      logging: [Function: log],
      omitNull: false,
      native: false,
      replication: false,
      ssl: undefined,
      pool: {},
      quoteIdentifiers: true,
      hooks: {},
      retry: [Object],
      transactionType: 'DEFERRED',
      isolationLevel: null,
      databaseVersion: 0,
      typeValidation: false,
      benchmark: false,
      minifyAliases: false,
      logQueryParameters: false,
      dialectOptions: [Object]
    },
    config: {
      database: 'dbname',
      username: 'username',
      password: 'password',
      host: 'localhost',
      port: 5432,
      pool: {},
      protocol: 'tcp',
      native: false,
      ssl: undefined,
      replication: false,
      dialectModule: null,
      dialectModulePath: null,
      keepDefaultTimezone: undefined,
      dialectOptions: [Object]
    },
    dialect: PostgresDialect {
      sequelize: [Circular *1],
      connectionManager: [ConnectionManager],
      QueryGenerator: [PostgresQueryGenerator]
    },
    queryInterface: QueryInterface {
      sequelize: [Circular *1],
      QueryGenerator: [PostgresQueryGenerator]
    },
    models: {},
    modelManager: ModelManager { models: [], sequelize: [Circular *1] },
    connectionManager: ConnectionManager {
      sequelize: [Circular *1],
      config: [Object],
      dialect: [PostgresDialect],
      versionPromise: [Promise [Object]],
      dialectName: 'postgres',
      pool: [Pool],
      lib: [PG],
      nameOidMap: {},
      enumOids: [Object],
      oidParserMap: Map(0) {}
    },
    importCache: {}
  }
}

I am able to successfully run this query through psql. Why am I not getting any query results through Sequelize?

Upvotes: 0

Views: 377

Answers (1)

sigil
sigil

Reputation: 9546

Figured it out--this issue has been addressed in depth here: https://github.com/sequelize/sequelize/issues/12158

Upvotes: 1

Related Questions