It is posible to disable the return id

16 views
Skip to first unread message

Jorge Cadena

unread,
Oct 13, 2017, 6:31:38 PM10/13/17
to Django users
Hola

I'm creating a partitioned table and the trigger return a NULL and django bounces an error because postgres doesn't return anything

It is posible to tell django to disable the return of the id

 django makes a mistake: 'NoneType' object is not subscriptable


Trigger in postgres:


CREATE OR REPLACE FUNCTION reportes_reportlega_insert()
RETURNS TRIGGER AS $$
BEGIN
     ELSIF ( NEW.create_at >= DATE '2017-10-01' AND NEW.create_at < DATE '2017-12-01') THEN
        INSERT INTO reportes_reportlega_201710 VALUES (NEW.*);
    ELSIF ( NEW.create_at >= DATE '2017-11-01' AND NEW.create_at < DATE '2018-01-01') THEN
        INSERT INTO reportes_reportlega_201711 VALUES (NEW.*);
    ELSIF ( NEW.create_at >= DATE '2017-12-01' AND NEW.create_at < DATE '2018-01-01') THEN
        INSERT INTO reportes_reportlega_201712 VALUES (NEW.*);
    ELSIF ( NEW.create_at >= DATE '2018-01-01' AND NEW.create_at < DATE '2018-02-01') THEN
        INSERT INTO reportes_reportlega_201801 VALUES (NEW.*);
    ELSIF ( NEW.create_at >= DATE '2018-02-01' AND NEW.create_at < DATE '2018-03-01') THEN
        INSERT INTO reportes_reportlega_201802 VALUES (NEW.*);
    ELSE
        RAISE EXCEPTION 'Date out of range.  Fix the reportes_reportlega_insert() function!';
    END IF;
    RETURN NULL;
END;
$$
LANGUAGE plpgsql;


https://github.com/django/django/blob/11ade8eefd32f5bc7ee6379b77824f02ca61c20b/django/db/backends/base/operations.py#L173


i don't know, if my english and explanation are okay.
Reply all
Reply to author
Forward
0 new messages