octaflow 0.36.0 → 0.36.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/dist/postgres/index.js +8 -1
- package/package.json +1 -1
package/dist/postgres/index.js
CHANGED
|
@@ -125,6 +125,13 @@ function poolExecutor(pool) {
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
|
+
* A `Date` parameter as its ISO string. Drizzle's postgres-js driver replaces the client's timestamp serializers with
|
|
129
|
+
* a pass-through (it serialises dates itself), so a `Date` handed to `sql.unsafe` on a client Drizzle wraps reaches
|
|
130
|
+
* the wire as an object and postgres.js throws ("The "string" argument must be of type string … Received an
|
|
131
|
+
* instance of Date"). The ISO string works on every client: Postgres casts it from the column or the comparison.
|
|
132
|
+
*/
|
|
133
|
+
const isoDates = (params) => params.map((p) => p instanceof Date ? p.toISOString() : p);
|
|
134
|
+
/**
|
|
128
135
|
* Build a {@link SqlExecutor} over a postgres.js `sql` instance: top-level
|
|
129
136
|
* queries run on its pool (autocommit); `transaction` runs `fn` inside
|
|
130
137
|
* `sql.begin`, so every query of `fn` shares one connection and a throw rolls
|
|
@@ -144,7 +151,7 @@ function poolExecutor(pool) {
|
|
|
144
151
|
function postgresJsExecutor(sql) {
|
|
145
152
|
const over = (conn, inTransaction) => ({
|
|
146
153
|
async query(text, params) {
|
|
147
|
-
const rows = await conn.unsafe(text, params ?? []);
|
|
154
|
+
const rows = await conn.unsafe(text, isoDates(params ?? []));
|
|
148
155
|
return {
|
|
149
156
|
rows: Array.from(rows),
|
|
150
157
|
rowCount: rows.count ?? rows.length
|
package/package.json
CHANGED