sequelize: Sequelize raw query does not returns the exact result from the Postgres DB
What are you doing?
I have a sequelize raw query to select some values from the database.But when running the query in postgres ie generated by sequelize gives 2 rows and in sequelize output ,it returns only 1 row.
const db = require('../models');
const invoices = await db.sequelize.query("SELECT invoice_amount, bill_period_from, bill_period_to FROM invoices WHERE invoices.user_id="+user_id+" and date_part('year', bill_period_from) = date_part('year', current_date) order by bill_period_from", { type: db.sequelize.QueryTypes.SELECT});
Query from the console
SELECT invoice_amount, bill_period_from, bill_period_to FROM invoices WHERE invoices.user_id=112 and date_part('year', bill_period_from) = date_part('year', current_date) order by bill_period_from
What do you expect to happen?
Output from Postgres DB has two rows but from the sequelize it has only one row
What is actually happening?
output from the console [ { invoice_amount: ‘120.000’, bill_period_from: 2018-01-31T18:30:00.000Z, bill_period_to: 2018-02-27T18:30:00.000Z } ]
output from the DB 300.000;“2018-01-01 00:00:00+05:30”;“2018-01-31 00:00:00+05:30” 120.000;“2018-02-01 00:00:00+05:30”;“2018-02-28 00:00:00+05:30”
Dialect: postgres Dialect version: XXX __Database version:9.5 __Sequelize version:3.0.0 Tested with latest release: No (If yes, specify that version)
Note : Your issue may be ignored OR closed by maintainers if it’s not tested against latest version OR does not follow issue template.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (5 by maintainers)
I am facing the same issue, return only the first row of the results, and return the query text, very weird …