k1LoW / tbls

tbls is a CI-Friendly tool for document a database, written in Go.
MIT License
3.4k stars 166 forks source link

Exclude all tables except specific table #369

Closed FelixZY closed 1 year ago

FelixZY commented 1 year ago

I have a database where I want to exclude all tables from the auth schema, except auth.users. This database also has tables in other schemas that I want to be included.

I tried

# .tbls.yml
include:
  - * # also `"*"`, `'*'`, `"**/*"` as well as removing this line
  - auth.users
exclude:
  - auth.*

However, this causes all output to be excluded, producing an empty output.

  1. How can I exclude all tables in the auth schema, except auth.users?
  2. How can I include all other tables when using an include section? (* does not seem to work when used alone)

Environment

k1LoW commented 1 year ago

exclude: and include: are shown in the following figure.

image

ref: https://github.com/k1LoW/tbls#filter-tables

How can I exclude all tables in the auth schema, except auth.users?

There may be no other way but to list.

How can I include all other tables when using an include section? (* does not seem to work when used alone)

tbls will target all tables even if nothing is specified. If the table you want is not output, it may not be included in the range of the DSN given to tbls.

Could you provide a schema (DDL) and DSN example ?

FelixZY commented 1 year ago

Hm, i guess that if it is not possible to include specific tables when using a general exclude, there is no point in doing

include:
  - "*"

If i skip the include section and use specific excludes, things work as expected, so I don't think an example is necessary. However, if I were to rephrase my question into a feature request:

Right now, logic is

  1. Add tables from include
  2. Remove tables from exclude
  3. Result

As a user, I would expect the logic to be

  1. Add tables from include
  2. Remove tables from exclude
  3. Check for include/exclude overlaps
  4. If include is more specific than exclude (i.e. schema.MyTable > schema.* or schema.MyT* > schema.*), include the table(s). If include is equally or less specific than exclude, exclude wins.
  5. Result
k1LoW commented 1 year ago

If include is more specific than exclude (i.e. schema.MyTable > schema. or schema.MyT > schema.*), include the table(s). If include is equally or less specific than exclude, exclude wins.

This logic is not included now. But it looks good to me.