The list of all the queries

Check as to wheteher the names of parameters are in the plural or in the singular form (Estonian version)

Query goal: Check as to wheteher the names of routine parameters are in the plural or in the singular form. Make sure that you are consistent in naming.
Notes about the query: The query does not consider objects that are a part of an extension. There could be multiple routines with the same name but with different parameters in the same schema (overloading). Thus, for the unique identification of the routine it is necessary to present also its parameters in addition to the schema name and routine name.
Query type: General (Overview of some aspect of the database.)
Query license: MIT License
Data source: INFORMATION_SCHEMA+system catalog
SQL query: Click on query to copy it

WITH params AS (SELECT 
specific_schema AS routine_schema,
regexp_replace(specific_name,'_[0-9]*$','') AS routine_name,
pg_get_function_identity_arguments(translate(substring(specific_name,'_[0-9]+$'),'_','')::int::oid) AS parameters,
parameter_name,
ordinal_position,
data_type
FROM 
information_schema.parameters
WHERE specific_schema NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL) 
AND NOT EXISTS (SELECT 1
FROM pg_catalog.pg_depend d inner join pg_catalog.pg_proc pc ON d.objid=pc.oid
WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_extension e WHERE d.refobjid=e.oid) AND
pc.proname || '_' || pc.oid = parameters.specific_name)),
plural_or_singular AS (SELECT routine_schema, routine_name, parameters, parameter_name, 
ordinal_position, data_type, 
CASE WHEN parameter_name ~* '(d$|.+(d|[^t]t)e_.+)' 
AND parameter_name !~*'((^|_)id$|kood$|(^|_)oid$|(^|_)uuid$|hind$|seisund$|brand$|^d*d$|periood$|arv$|laud$|kraad$|l(ü|y)hend$)' 
THEN 'Perhaps plural' ELSE 'Perhaps singular' END AS comment_about_the_parameter_name
FROM params)
SELECT routine_schema, routine_name, parameters, parameter_name, ordinal_position, data_type, comment_about_the_parameter_name,
CASE WHEN comment_about_the_parameter_name='Perhaps plural' AND data_type!~*'(array|json|xml|int|numeric|float)' THEN 'Perhaps should be singular'
WHEN comment_about_the_parameter_name='Perhaps singular' AND data_type~*'(array|json|xml)' THEN 'Perhaps should be plural'
ELSE 'OK' END AS evaluation
FROM plural_or_singular
ORDER BY evaluation DESC, comment_about_the_parameter_name, routine_schema, routine_name, parameters;

Categories where the query belongs to

Category nameCategory description
InconsistenciesQueries of this catergory provide information about inconsistencies of solving the same problem in different places.
NamingQueries of this category provide information about the style of naming.

Reference materials for further reading

Reference
Linguistic antipatterns "D.1 Says one but contains many" and "E.1 Says many but contains one": Arnaoudova, V., Di Penta, M., Antoniol, G., 2016. Linguistic antipatterns: What they are and how developers perceive them. Empirical Software Engineering, 21(1), pp.104-158.

The list of all the queries