Skip to content

Commit 1df4286

Browse files
acarstoiuporsager
authored andcommitted
Allow for incomplete custom types
Specifically, I'd like to be able to get away with a type definition consisting in just the `to` property, like this: ` int4: { to: 23 } ` That's because I mereley want to use a name for a Postgres type OID and the usual conversions are already defined in this file. As a fallback, the default serialization in src/connection.js at line 912 is just fine.
1 parent 82908d3 commit 1df4286

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/types.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,10 @@ export const mergeUserTypes = function(types) {
201201
function typeHandlers(types) {
202202
return Object.keys(types).reduce((acc, k) => {
203203
types[k].from && [].concat(types[k].from).forEach(x => acc.parsers[x] = types[k].parse)
204-
acc.serializers[types[k].to] = types[k].serialize
205-
types[k].from && [].concat(types[k].from).forEach(x => acc.serializers[x] = types[k].serialize)
204+
if (types[k].serialize) {
205+
acc.serializers[types[k].to] = types[k].serialize
206+
types[k].from && [].concat(types[k].from).forEach(x => acc.serializers[x] = types[k].serialize)
207+
}
206208
return acc
207209
}, { parsers: {}, serializers: {} })
208210
}

0 commit comments

Comments
 (0)