Skip to content

Commit 3ed11e7

Browse files
committed
Parse update properly with identity full - Fixes porsager#296
1 parent 4988851 commit 3ed11e7

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/subscribe.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function parse(x, state, parsers, handle) {
180180
? {}
181181
: null
182182

183-
old && (i = tuples(x, old, key ? relation.keys : relation.columns, ++i))
183+
old && (i = tuples(x, old, key ? relation.keys : relation.columns, i += 3))
184184

185185
const row = {}
186186
i = tuples(x, row, relation.columns, i += 3)

tests/index.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1712,8 +1712,8 @@ t('subscribe', { timeout: 2 }, async() => {
17121712

17131713
const result = []
17141714

1715-
await sql.subscribe('*', (row, info) =>
1716-
result.push(info.command, row.name || row.id)
1715+
await sql.subscribe('*', (row, { command, old }) =>
1716+
result.push(command, row.name || row.id, old && old.name)
17171717
)
17181718

17191719
await sql`
@@ -1722,12 +1722,17 @@ t('subscribe', { timeout: 2 }, async() => {
17221722
name text
17231723
)
17241724
`
1725+
1726+
await sql`insert into test (name) values ('Murray')`
1727+
await sql`update test set name = 'Rothbard'`
1728+
await sql`delete from test`
1729+
await sql`alter table test replica identity full`
17251730
await sql`insert into test (name) values ('Murray')`
17261731
await sql`update test set name = 'Rothbard'`
17271732
await sql`delete from test`
17281733
await delay(100)
17291734
return [
1730-
'insert,Murray,update,Rothbard,delete,1',
1735+
'insert,Murray,,update,Rothbard,,delete,1,,insert,Murray,,update,Rothbard,Murray,delete,Rothbard,',
17311736
result.join(','),
17321737
await sql`drop table test`,
17331738
await sql`drop publication alltables`,

0 commit comments

Comments
 (0)