Skip to content

False positive for function does not exist #482

@reteps

Description

@reteps

Bug report

apps/prairielearn/src/lib/assessment.sql:1509:7 typecheck ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   function array_avg(double precision[]) does not exist

    1507        avg(iq.max_submission_score) AS max_submission_score,
    1508        avg(iq.average_submission_score) AS average_submission_score,
  > 1509        array_avg (iq.submission_score_array) AS submission_score_array,
                ^^^^^^^^^
    1510        array_avg (iq.incremental_submission_score_array) AS incremental_submission_score_array,
    1511        array_avg (iq.incremental_submission_points_array) AS incremental_submission_points_array,

   Error Code: 42883

   Hint: No function matches the given name and argument types. You might need to add explicit type casts.

Describe the bug

  • Define a sproc in a non-public schema, it isn't picked up.
postgres=# select routine_schema, routine_name
from information_schema.role_routine_grants rrg
where routine_name ='array_avg' order by routine_schema asc, specific_name asc, routine_name asc;
               routine_schema                | routine_name
---------------------------------------------+--------------
 server:3000_2025-08-21T17:47:18.085Z_YT0E23 | array_avg
 server:3000_2025-08-21T17:47:18.085Z_YT0E23 | array_avg
 server:3000_2025-08-22T19:00:29.534Z_5ZHDV4 | array_avg
 server:3000_2025-08-22T19:00:29.534Z_5ZHDV4 | array_avg

To Reproduce

Reproduction in PrairieLearn/PrairieLearn#12682

yarn postgrestools check apps/prairielearn/src

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • macOS, Postgres 16.9

Additional context

Config:

{
  "$schema": "https://pgtools.dev/main/schema.json",
  "vcs": {
    "enabled": true,
    "clientKind": "git",
    "useIgnoreFile": true
  },
  "migrations": {
    "migrationsDir": "apps/prairielearn/src/migrations"
  },
  "files": {
    "ignore": []
  },
  "linter": {
    "rules": {
      "recommended": true
    }
  },
  "db": {
    "host": "127.0.0.1",
    "port": 5432,
    "username": "postgres",
    "database": "postgres",
    "connTimeoutSecs": 10
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions