I am using KnexJS to fetch data from PostgreSQL and in some places, I use the following pattern:-
select to_jsonb(s.*) as student, to_jsonb(st.*) as subject_test
from subject_tests st
inner join students s on st.student_id = s.id
where st.date >= '...'
The problem I am facing is that if the id
column in subject_test
table is a bigint, I get it back as a number in the subject_test
object. This can be inaccurate since bigint is able to store beyond the range of javascript number type. Why does to_jsonb
not convert bigint to string in json instead? Is there a way to fix this?