Skip to content

feat: filtering by schema(s) for tables, columns, types, policies and functions #375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 23, 2022

Conversation

osaxma
Copy link
Contributor

@osaxma osaxma commented Oct 7, 2022

What kind of change does this PR introduce?

This PR introduces a new feature that allows filtering by schema(s) for the following:

What is the current behavior?

Currently, it's not possible to filter by schema(s).

What is the new behavior?

This PR allows filtering the given endpoints with a list of schemas using either included_schemas or excluded_schemas as a query parameter.

Example Usage:

curl 'http://0.0.0.0:1337/tables?included_schemas=public'
curl 'http://0.0.0.0:1337/columns?included_schemas=public,core,private'
curl 'http://0.0.0.0:1337/functions?excluded_schemas=public'
curl 'http://0.0.0.0:1337/types?excluded_schemas=pg_catalog&include_system_schemas=true'

Additional context

Currently, it's only possible to pass schema(s) as a comma separated values (i.e., "...?included_schemas=public,core").

When I tried defining included_schemas or excluded_schemas as string[] such as:

  fastify.get<{
    ....
    Querystring: {
      included_schemas?: string[] 
      excluded_schemas?: string[]
    }
   ....
  }>

Single value and comma separated values were still parsed as a string. This type argument would parse an array only if the parameter was passed multiple times (e.g. "...?included_schemas=public&included_schemas=core"). Based on a quick research, it seems arrays can be parsed correctly when using JSON Schema instead of generics but I didn't want to complicate this PR. So the API with this change will be limited to comma separated values for included_schemas and excluded_schemas parameters.

@osaxma osaxma requested a review from a team as a code owner October 7, 2022 23:05
@sweatybridge
Copy link
Contributor

sweatybridge commented Dec 23, 2022

I've updated your PR with support for triggers and views. Supersedes #440

@osaxma
Copy link
Contributor Author

osaxma commented Dec 23, 2022

thanks @sweatybridge !

@osaxma osaxma deleted the include_exclude_options branch December 23, 2022 06:54
@github-actions
Copy link

🎉 This issue has been resolved in version 0.55.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

avallete pushed a commit that referenced this pull request May 13, 2025
feat: filtering by schema(s) for tables, columns, types, policies and functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass Excluded Schemas When Retrieving List of All Functions
2 participants