mirror of
https://github.com/sprockets/sprockets-postgres.git
synced 2024-11-14 03:00:19 +00:00
664bedbb24
ProgrammingError is raised when you try and fetch data from a cursor and there is no data to fetch. When this happens ProgrammingError.pgcode is None. It is also raised when your query has errors in it. Now if that's the case, they will be caught on L249 and not inside the function at L259. This new branch in the code will ensure that should we unexpectedly encounter a "real" programming error from Postgres, it is not blindly swallowed and a warning is issued. This should NEVER happen based upon my understanding of the psycopg2 internals. Unfortunately I couldn't come up with a good test case using mocks to make it happen, as ProgrammingError() takes no keyword arguments and pgcode is a read-only attribute on a ProgrammingError instance. I also couldn't figure out a way to raise ProgrammingError from psycopg2.errors.lookup/1. Thus, the # pragma: nocover
36 lines
1.5 KiB
SQL
36 lines
1.5 KiB
SQL
CREATE EXTENSION "uuid-ossp";
|
|
|
|
CREATE TABLE public.test (
|
|
id UUID NOT NULL PRIMARY KEY,
|
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
last_modified_at TIMESTAMP WITH TIME ZONE,
|
|
value TEXT NOT NULL
|
|
);
|
|
|
|
CREATE TABLE public.query_count(
|
|
key TEXT NOT NULL PRIMARY KEY,
|
|
last_updated_at TIMESTAMP WITH TIME ZONE,
|
|
count INTEGER
|
|
);
|
|
|
|
INSERT INTO public.query_count (key, last_updated_at, count)
|
|
VALUES ('test', CURRENT_TIMESTAMP, 0);
|
|
|
|
CREATE TABLE public.test_rows (
|
|
id INTEGER NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
|
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
last_modified_at TIMESTAMP WITH TIME ZONE,
|
|
toggle BOOLEAN NOT NULL
|
|
);
|
|
|
|
INSERT INTO public.test_rows (toggle) VALUES (FALSE);
|
|
INSERT INTO public.test_rows (toggle) VALUES (FALSE);
|
|
INSERT INTO public.test_rows (toggle) VALUES (FALSE);
|
|
INSERT INTO public.test_rows (toggle) VALUES (FALSE);
|
|
INSERT INTO public.test_rows (toggle) VALUES (FALSE);
|
|
|
|
CREATE TABLE public.row_count_no_rows (
|
|
id INTEGER NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
|
|
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
value UUID NOT NULL DEFAULT uuid_generate_v4()
|
|
);
|