@teamkeel/functions-runtime 0.384.0 → 0.386.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamkeel/functions-runtime",
3
- "version": "0.384.0",
3
+ "version": "0.386.0-next.1",
4
4
  "description": "Internal package used by @teamkeel/sdk",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -27,6 +27,7 @@ beforeEach(async () => {
27
27
  id text PRIMARY KEY,
28
28
  title text,
29
29
  tags text[],
30
+ rating numeric,
30
31
  author_id text references person(id)
31
32
  );
32
33
  CREATE TABLE author(
@@ -124,9 +125,11 @@ test("ModelAPI.create - arrays", async () => {
124
125
  id: "id",
125
126
  title: "My Post",
126
127
  tags: ["tag 1", "tag 2"],
128
+ rating: 1.23,
127
129
  authorId: person.id,
128
130
  });
129
131
  expect(row.tags).toEqual(["tag 1", "tag 2"]);
132
+ expect(row.rating).toEqual(1.23);
130
133
  });
131
134
 
132
135
  test("ModelAPI.findOne", async () => {
package/src/database.js CHANGED
@@ -142,6 +142,12 @@ function getDialect() {
142
142
  const dbConnType = process.env["KEEL_DB_CONN_TYPE"];
143
143
  switch (dbConnType) {
144
144
  case "pg":
145
+ // Adding a custom type parser for numeric fields: see https://kysely.dev/docs/recipes/data-types#configuring-runtime-javascript-types
146
+ // 1700 = type for NUMERIC
147
+ pg.types.setTypeParser(1700, function (val) {
148
+ return parseFloat(val);
149
+ });
150
+
145
151
  return new PostgresDialect({
146
152
  pool: new InstrumentedPool({
147
153
  Client: InstrumentedClient,