squawk icon indicating copy to clipboard operation
squawk copied to clipboard

Squawk Not Detecting Errors in PostgreSQL Function Body

Open salgado-unleashed opened this issue 10 months ago • 2 comments

I'm trying to use squawk to lint a PostgreSQL function, but it seems like the function body is not being checked properly. To test this, I deliberately introduced a syntax error (SELEC instead of SELECT), but squawk did not flag it as an issue. Is there a known limitation with squawk when linting PostgreSQL functions?

  1. Create a SQL file (get_city_by_id.sql) with the following function:
CREATE OR REPLACE FUNCTION world.get_city_by_id(p_city_id BIGINT)
RETURNS TABLE(city_id BIGINT, city_name VARCHAR, country_id INT) AS
$$
BEGIN
    RETURN QUERY
    SELEC city_id, city_name, country_id
    FROM world.city
    WHERE city_id = p_city_id;
END;
$$ LANGUAGE plpgsql;
$ squawk get_city_by_id.sql --verbose
01:31:30 [INFO] no config file found
01:31:30 [INFO] pg version: None
01:31:30 [INFO] excluded rules: []
01:31:30 [INFO] excluded paths: []
01:31:30 [INFO] assume in a transaction: false
01:31:30 [INFO] checking file path: get_city_by_id.sql
Found 0 issues in 1 file 🎉

Does squawk support linting inside plpgsql function bodies? Are there any configuration options required to enable deeper analysis?

salgado-unleashed avatar Feb 18 '25 01:02 salgado-unleashed