Pyrseas icon indicating copy to clipboard operation
Pyrseas copied to clipboard

schema name support in table inclusion/exclusion (-t/-T) options

Open kowloon12 opened this issue 7 years ago • 4 comments

It would be very useful being able to also specify the schema with -t and -T options (like the pg_dump's options) to address the potential homonymy between tables of different schemas.

kowloon12 avatar Feb 09 '17 15:02 kowloon12

Just to make it clear (and to provide an example for further testing), I presume you'd like to be able to specify t <schema>.<table>, rather than use -n <schema> -t <table>?

For example, using the autodoc database (see tests/functional/autodoc-schema.sql), if you run

dbtoyaml -t warehouse.inventory autodoc

you don't get any tables. If you run

dbtoyaml -t inventory autodoc

the output includes both store.inventory and warehouse.inventory. And if you run

dbtoyaml -n store -t inventory autodoc

the output is limited to store.inventory which already takes care of the homonym problem (but maybe it has some other side effects, I'm not sure?).

jmafc avatar Feb 09 '17 17:02 jmafc

Sometimes there is the need to process more than one schema in a single dump (think for example if you have a table with a foreign to an object in another schema) and if those schemas contain tables with the same name it's impossible to include/exclude only a subset of them without using the schema name.

e.g.

Schema1.table1 Schema1.table5 Schema1.table7

Schema2.table3 Schema2.table4 Schema2.table5

If I want to dump those two schema excluding the table5 of schema2 but not the one in schema1 I currently need to dump the two schemas and then edit the file..

Maybe I'm missing something?

I hope to have explained it well enough despite my bad English..

p.s. wildcard support would be great, also.

On 9 Feb 2017 6:47 pm, "Joe Abbate" [email protected] wrote:

Just to make it clear (and to provide an example for further testing), I presume you'd like to be able to specify t ., rather than use -n -t
?

For example, using the autodoc database (see tests/functional/autodoc- schema.sql), if you run

dbtoyaml -t warehouse.inventory autodoc

you don't get any tables. If you run

dbtoyaml -t inventory autodoc

the output includes both store.inventory and warehouse.inventory. And if you run

dbtoyaml -n store -t inventory autodoc

the output is limited to store.inventory which already takes care of the homonym problem (but maybe it has some other side effects, I'm not sure?).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/perseas/Pyrseas/issues/156#issuecomment-278717744, or mute the thread https://github.com/notifications/unsubscribe-auth/AIPcXIvjVNQYQv0d5OTA9aQ9anhqVon3ks5ra1EfgaJpZM4L8SaK .

kowloon12 avatar Feb 09 '17 23:02 kowloon12

@kowloon12 I understand your requirements now.

Although much of dbtoyaml has tried to emulate the behaviour of pg_dump, the table and schema inclusion and exclusion processing has been more of an afterthought so it may require a significant amount of code rework to get what you want.

Currently the core of the table inclusion logic happens in the section starting at https://github.com/perseas/Pyrseas/blob/r0.7/pyrseas/dbobject/schema.py#L57 . As you may see there is no attempt at splitting schemas from tables in the list handed down from dbtoyaml -t arguments (at this level, they're in opts.tables) and we also look for full table names (although poor man's "wildcards" could be implemented by looking for partial string matches). Unfortunately, table exclusion is done elsewhere (look for excl_tables in the code).

jmafc avatar Feb 13 '17 20:02 jmafc

@kowloon12 Please read https://pyrseas.wordpress.com/2018/09/12/the-future-of-pyrseas-revisited/ . I'm afraid if I had to rank each issue according to priority this issue would be among the last.

jmafc avatar Sep 14 '18 01:09 jmafc