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.
-- 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.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fbffe365-cca0-46c8-b6cd-e4a088dc23a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment