Columns are being stringified at random

Hi everyone. In my JSON response object , some numeric fields are being turned into strings, whereas otehr fileds are kept in their oiginal numeric format. Why? Is this a config problem? Can I do somethign about it? The schema is correctly typed, but when I fetch some fields get turned into text whereas others do not. Thanks in advance for any help ! For context, this is the fucntion:
export const fetchAllServicesWithProfiles = async () => {
const result = await db
.select({
id: services.id,
category: services.category,
service: services.service,
description: services.description,
unit: services.unit,
duration: services.duration,
personnel: services.personnel,
included: services.included,

price: serviceProfiles.price,
sale: serviceProfiles.sale,
saleExpiresBy: serviceProfiles.saleExpiresBy,
popularity: serviceProfiles.popularity,

})
.from(services)
.innerJoin(serviceProfiles, eq(services.id, serviceProfiles.serviceId));
return result;
};
export const fetchAllServicesWithProfiles = async () => {
const result = await db
.select({
id: services.id,
category: services.category,
service: services.service,
description: services.description,
unit: services.unit,
duration: services.duration,
personnel: services.personnel,
included: services.included,

price: serviceProfiles.price,
sale: serviceProfiles.sale,
saleExpiresBy: serviceProfiles.saleExpiresBy,
popularity: serviceProfiles.popularity,

})
.from(services)
.innerJoin(serviceProfiles, eq(services.id, serviceProfiles.serviceId));
return result;
};
For example, price is a number, but is being returned as a string. Personnel is a number and is being returned as a number. I can't figure this out.
Solution:
What is the exact column type you're using for price? - numeric and decimal (exact precision) are input/output as a string - real and double precision (variable precision) are input/output as numbers...
Jump to solution
2 Replies
Solution
Sillvva
Sillvva8mo ago
What is the exact column type you're using for price? - numeric and decimal (exact precision) are input/output as a string - real and double precision (variable precision) are input/output as numbers
nr7751
nr7751OP8mo ago
@Sillvva , Ah, I see the issue now. It's "integer" vs "numeric". Thanks!
Want results from more Discord servers?
Add your server