我收到此错误error: null value in column "reimb_amount" violates not-null constraint
我所有的列实际上都返回null。 detail:
'Failing row contains (23, null, null, null, null, null, null, null, null).',
但是在我的邮递员中,我确保将所有列填充为这样发送到数据库。
{
"reimb_amount": 400,
"reimb_submitted": {{$timestamp}},
"reimb_resolved": {{$timestamp}},
"reimb_description": "Travel to Alaska",
"reimb_author": 8,
"reimb_resolver": 1,
"reimb_status_id": 1,
"reimb_type_id": 2
}
我的DAO看起来像这样
// * @param reimbursement
export async function createReimbursement(reimbursement:
ReimbRequest): Promise<number> {
const client = await connectionPool.connect();
try {
const res = await client.query(
`INSERT INTO expense_reimbursement.ers_reimbursement
(reimb_amount, reimb_submitted, reimb_description, reimb_author,
reimb_status_id, reimb_type_id )
VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING reimb_id`,[
reimbursement.amount,
reimbursement.submitted,
reimbursement.description,
reimbursement.author,
reimbursement.resolver,
reimbursement.status,
reimbursement.type
]
);
return res.rows[0].reimb_id;
} finally {
client.release();
}
}
如果您需要查看其他内容,请告诉我。感谢您的帮助。
答案 0 :(得分:1)
邮递员中应该只有金额而不是reimbursement.reimb_amount