Skip to content

Commit b298634

Browse files
committed
Move types to won namespace
1 parent 9709996 commit b298634

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ export default function Postgres(url, options) {
268268

269269
function addTypes(sql, connection) {
270270
Object.assign(sql, {
271+
types: {},
271272
notify,
272273
unsafe,
273274
array,
@@ -313,7 +314,7 @@ export default function Postgres(url, options) {
313314
if (name in sql)
314315
throw errors.generic({ message: name + ' is a reserved method name', code: 'RESERVED_METHOD_NAME' })
315316

316-
sql[name] = (x) => ({ type: type.to, value: x })
317+
sql.types[name] = (x) => ({ type: type.to, value: x })
317318
})
318319
}
319320

tests/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ t('Point type', async() => {
228228
})
229229

230230
await sql`create table test (x point)`
231-
await sql`insert into test (x) values (${ sql.point([10, 20]) })`
231+
await sql`insert into test (x) values (${ sql.types.point([10, 20]) })`
232232
return [20, (await sql`select x from test`)[0].x[1]]
233233
}, () => sql`drop table test`)
234234

@@ -246,7 +246,7 @@ t('Point type array', async() => {
246246
})
247247

248248
await sql`create table test (x point[])`
249-
await sql`insert into test (x) values (${ sql.array([sql.point([10, 20]), sql.point([20, 30])]) })`
249+
await sql`insert into test (x) values (${ sql.array([sql.types.point([10, 20]), sql.types.point([20, 30])]) })`
250250
return [30, (await sql`select x from test`)[0].x[1][1]]
251251
}, () => sql`drop table test`)
252252

0 commit comments

Comments
 (0)