Skip to content

Commit

Permalink
style: use constants for pg types
Browse files Browse the repository at this point in the history
  • Loading branch information
RutZap committed Jan 21, 2025
1 parent 07866c9 commit bf079e1
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/functions-runtime/src/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ function getDialect(connString) {
case "pg":
// Adding a custom type parser for numeric fields: see https://kysely.dev/docs/recipes/data-types#configuring-runtime-javascript-types
// 1700 = type for NUMERIC
pg.types.setTypeParser(1700, function (val) {
pg.types.setTypeParser(pg.types.builtins.NUMERIC, function (val) {
return parseFloat(val);
});
// Adding a custom type parser for interval fields: see https://kysely.dev/docs/recipes/data-types#configuring-runtime-javascript-types
// 1186 = type for INTERVAL
pg.types.setTypeParser(1186, function (val) {
pg.types.setTypeParser(pg.types.builtins.INTERVAL, function (val) {
return new Duration(val);
});

Expand Down Expand Up @@ -185,14 +185,20 @@ function getDialect(connString) {
case "neon":
// Adding a custom type parser for numeric fields: see https://kysely.dev/docs/recipes/data-types#configuring-runtime-javascript-types
// 1700 = type for NUMERIC
neonserverless.types.setTypeParser(1700, function (val) {
return parseFloat(val);
});
neonserverless.types.setTypeParser(
pg.types.builtins.NUMERIC,
function (val) {
return parseFloat(val);
}
);
// Adding a custom type parser for interval fields: see https://kysely.dev/docs/recipes/data-types#configuring-runtime-javascript-types
// 1186 = type for INTERVAL
neonserverless.types.setTypeParser(1186, function (val) {
return new Duration(val);
});
neonserverless.types.setTypeParser(
pg.types.builtins.INTERVAL,
function (val) {
return new Duration(val);
}
);

neonserverless.neonConfig.webSocketConstructor = ws;

Expand Down

0 comments on commit bf079e1

Please sign in to comment.