Giter Site home page Giter Site logo

Comments (11)

kiwicopple avatar kiwicopple commented on May 5, 2024 1

OK found the issue:

Enum.each change.record, fn {k, v} ->

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.

awalias avatar awalias commented on May 5, 2024

thanks @SweeToxin we'll try and reproduce.

@phamhieu since you were testing realtime + dart, did you happen to test deletes today?

from realtime.

phamhieu avatar phamhieu commented on May 5, 2024

I only tested INSERT. I will check it again later.

from realtime.

kiwicopple avatar kiwicopple commented on May 5, 2024

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.

SweeToxin avatar SweeToxin commented on May 5, 2024

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.

kiwicopple avatar kiwicopple commented on May 5, 2024

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.

SweeToxin avatar SweeToxin commented on May 5, 2024

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.

soedirgo avatar soedirgo commented on May 5, 2024

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.

SweeToxin avatar SweeToxin commented on May 5, 2024

Hey @soedirgo,
Thank you for taking the time to look into this

from realtime.

github-actions avatar github-actions commented on May 5, 2024

🎉 This issue has been resolved in version 0.7.11 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

from realtime.

kiwicopple avatar kiwicopple commented on May 5, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.