2023-02-09 10:42:31 +00:00
|
|
|
-- Verify numerus:invoice on pg
|
|
|
|
|
|
|
|
begin;
|
|
|
|
|
|
|
|
select invoice_id
|
|
|
|
, company_id
|
|
|
|
, slug
|
|
|
|
, invoice_number
|
|
|
|
, invoice_date
|
|
|
|
, contact_id
|
|
|
|
, invoice_status
|
|
|
|
, notes
|
Replace tag relations with array attributes
It all started when i wanted to try to filter invoices by multiple tags
using an “AND”, instead of “OR” as it was doing until now. But
something felt off and seemed to me that i was doing thing much more
complex than needed, all to be able to list the tags as a suggestion
in the input field—which i am not doing yet.
I found this article series[0] exploring different approaches for
tagging, which includes the one i was using, and comparing their
performance. I have not actually tested it, but it seems that i have
chosen the worst option, in both query time and storage.
I attempted to try using an array attribute to each table, which is more
or less the same they did in the articles but without using a separate
relation for tags, and i found out that all the queries were way easier
to write, and needed two joins less, so it was a no-brainer.
[0]: http://www.databasesoup.com/2015/01/tag-all-things.html
2023-04-07 19:31:35 +00:00
|
|
|
, tags
|
2023-03-05 17:50:57 +00:00
|
|
|
, payment_method_id
|
2023-02-09 10:42:31 +00:00
|
|
|
, currency_code
|
|
|
|
, created_at
|
|
|
|
from numerus.invoice
|
|
|
|
where false;
|
|
|
|
|
|
|
|
select 1 / count(*) from pg_class where oid = 'numerus.invoice'::regclass and relrowsecurity;
|
|
|
|
select 1 / count(*) from pg_policy where polname = 'company_policy' and polrelid = 'numerus.invoice'::regclass;
|
|
|
|
|
|
|
|
rollback;
|