Comments (11)
OK found the issue:
This is mapping through the keys in record
, however a DELETE change looks like this:
{
"columns": [
{
"flags": [
"key"
],
"name": "id",
"type": "int4",
"type_modifier": 4294967295
},
{
"flags": [],
"name": "test_col",
"type": "varchar",
"type_modifier": 4294967295
}
],
"commit_timestamp": "2020-11-10T08:05:32Z",
"old_record": {
"id": "3",
"test_col": "qwe"
},
"record": {},
"schema": "public",
"table": "test_table",
"type": "DELETE"
}
There are no keys in record
, because it's a deletion. For DELETE's, we would need to loop through the old_record
.
@soedirgo I wonder if you roll this update into your changes in #76 ?
from realtime.
thanks @SweeToxin we'll try and reproduce.
@phamhieu since you were testing realtime + dart, did you happen to test deletes today?
from realtime.
I only tested INSERT. I will check it again later.
from realtime.
Hi @SweeToxin ! Nice to see you in our repos too
Could you please try this?
supabase.from(`${table}:${column}=eq.${value}`)
.on('DELETE', (change) => console.log('Change:', change))
.subscribe() // <---- add the subscribe function here
from realtime.
Thank you @kiwicopple!
Sorry I might have wrote the example code wrong, I will correct it.
I am actually using the .subscribe()
The code is working perfectly for INSERT and UPDATE, the issue only shows on DELETE subscription.
from realtime.
OK, can you try one more thing @SweeToxin ? Can you run
ALTER TABLE your_table REPLICA IDENTITY FULL;
on whichever table you're listening to?
from realtime.
Hey,
After trying that, it still doesn't work for DELETE ( both insert and update are working fine ).
This is the actual code if it helps
function startRealTime(table, store, userId) {
supabase
.from(`${table}:owner=eq.${userId}`)
.on('INSERT', onItemChange(store))
.on('UPDATE', onItemChange(store))
.on('DELETE', onItemDelete(store))
.subscribe();
}
from realtime.
I'm able to reproduce this with this setup:
supabase-js:
<!DOCTYPE html>
<html>
<script type="module">
import { createClient } from "https://cdn.skypack.dev/@supabase/supabase-js";
const supabase = createClient("https://[...].supabase.co", "[...]");
supabase
.from("users:id=eq.1")
.on("INSERT", (payload) => {
console.log("Insert received!", payload);
})
.on("UPDATE", (payload) => {
console.log("Update received!", payload);
})
.on("DELETE", (payload) => {
console.log("Delete received!", payload);
})
.subscribe();
</script>
</html>
Supabase:
CREATE TABLE users (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name text
);
insert into users (name) values ('a');
update users set name = 'b' where id = 1;
delete from users where id = 1;
Will look into this!
from realtime.
Hey @soedirgo,
Thank you for taking the time to look into this
from realtime.
🎉 This issue has been resolved in version 0.7.11 🎉
The release is available on GitHub release
Your semantic-release bot 📦🚀
from realtime.
Thanks for the patience on this one @SweeToxin - I just pushed the fix, and we will bundle it into the next deployment in supabase.
from realtime.
Related Issues (20)
- log_min_messages requires elevated privileges HOT 1
- Docker hub `latest` image tag is very old HOT 3
- What version of realtime is hosted Supabase using? HOT 1
- Add region to all Logger metadatas
- Realtime: Self Hosting - Docker Swarm mode HOT 6
- Docker-compose file appears to be broken HOT 40
- Unable to use null filters like 'parent IS NULL' in supabase realtime. HOT 3
- How is postgres binary data serialized?
- > Does supabase have null filters? HOT 1
- Self hosted : failed to connect: ** (Postgrex.Error) ssl not available HOT 1
- Startup error running migrations: table identifier does not refer to an existing ETS table HOT 8
- Erroneous public.test_tenant file from Supabase Realtime Migrations HOT 5
- Supabase Realtime Subscript Fails With Undefined Error (Possibly: `Auth error: tenant 'realtime-dev' not found` HOT 15
- supabase realtime not working HOT 26
- Seeds broken in latest docker image HOT 2
- horizontal scaling for self-hosted realtime servers, for broadcast and presence features HOT 5
- HTTP 431 & Realtime Subscriptions Failing HOT 11
- Realtime event broadcasting through REST calls does not work HOT 8
- Excessive logs being printed to STD OUT/ERR HOT 1
- [Broken] Custom primary keys (nanoids) breaks realtime listeners
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from realtime.