vanstyn / RapidApp

Turnkey ajaxy webapps
http://rapi.io
Other
48 stars 15 forks source link

Add option to rdbic.pl to control which db schemas are scanned #152

Closed timbunce closed 8 years ago

timbunce commented 9 years ago

We've a large database with many tables and a number of schema. One of the schemas causes a problem for rdbic.pl:

Unable to load schema - chosen moniker/class naming style results in moniker clashes. Change the naming style, or supply an explicit moniker_map: tried disambiguating by moniker_parts, but tables "old_mls_boards"."mls_listings_features", "old_mls_boards"."_mls_listings_features" still reduced to the same source moniker 'OldMlsBoardsMlsListingsFeature'; tried disambiguating by moniker_parts, but tables "old_mls_boards"."_mls_listings_log_status", "old_mls_boards"."mls_listings_log_status" still reduced to the same source moniker 'OldMlsBoardsMlsListingsLogStatus'; tried disambiguating by moniker_parts, but tables "old_mls_boards"."_mls_listings_log_price", "old_mls_boards"."mls_listings_log_price" still reduced to the same source moniker 'OldMlsBoardsMlsListingsLogPrice'; tried disambiguating by moniker_parts, but tables "old_mls_boards"."_mls_subdivisions", "old_mls_boards"."mls_subdivisions" still reduced to the same source moniker 'OldMlsBoardsMlsSubdivision'; tried disambiguating by moniker_parts, but tables "old_mls_boards"."_mls_offices", "old_mls_boards"."mls_offices" still reduced to the same source moniker 'OldMlsBoardsMlsOffice'; tried disambiguating by moniker_parts, but tables "old_mls_boards"."mls_agents", "old_mls_boards"."_mls_agents" still reduced to the same source moniker 'OldMlsBoardsMlsAgent'; tried disambiguating by moniker_parts, but tables "old_mls_boards"."mls_listings", "old_mls_boards"."_mls_listings" still reduced to the same source moniker 'OldMlsBoardsMlsListing'; tried disambiguating by moniker_parts, but tables "old_mls_boards"."mls_listings_images", "old_mls_boards"."_mls_listings_images" still reduced to the same source moniker 'OldMlsBoardsMlsListingsImage'

Some way to tell rdbic.pl which schema to include and/or exclude would be handy. In this case I could exclude that one schema. I can imagine that some people would want to explicitly include certain schema.

timbunce commented 9 years ago

Related: An option to filter tables based on regex would also be useful.

timbunce commented 8 years ago

Hello again! I just tried using the latest RapidApp and hit this need again. I can't get the --limit-schemas-re='...' to work for me. If I specify --limit-schemas-re='foo' where foo is the name of the schema, then it matches nothing and I get a No sources found (did you forget to define your tables?) warning. Same for --limit-schemas-re='.*foo.*' This is with pg 9.5, DBI 1.633, DBD::Pg 3.5.1.

vanstyn commented 8 years ago

@timbunce - give 7878829cc a try and see if it solves your problem. If so, I'll cut a new release shortly

vanstyn commented 8 years ago

@timbunce - it turns out this is a bit more complicated to be able to correctly handle all cases in all databases (the previous commit I made solved the problem for Pg but ended up breaking for MSSQL). In the commit I just made (40f371ae54d) I've handled this in the more robust/proper manner, which is to just fully expose Schema::Loader options so the user can just set the db_schema option directly.

To test this commit, you'll want to use this alternative option to rdbic.pl, instead of using the --limit-schemas-ra option at all:

  --loader-option db_schema=foo

This is just a pass-through to https://metacpan.org/pod/DBIx::Class::Schema::Loader::Base#db_schema and is probably the way I should have handled this to begin with. Also, this option is available in rapidapp.pl instead of only rdbic.pl. Docs and examples have been updated in this commit, too.

Give it a try and let me know how it works...

timbunce commented 8 years ago

Sounds good. I'm away for a few days. I'll try out your 1.1006 release when I'm back.

timbunce commented 8 years ago

Just got a moment to try this. I ran rdbic.pl 'dbi:Pg(pg_server_prepare=0):host=db-corp-stag.tigerlead.local;port=6000;dbname=corp,tigerweb' --loader-option db_schema=amq and (after the usual lots of warnings about odd tables in our db) got the rDbicServer UI showing all the tables in the public (default) schema and none of the ones in the 'amq' schema I wanted to use.

timbunce commented 8 years ago

Scratch that. I see at the start it said Unknown option: --loader-option so something went wrong with my upgrade. (Might be a good idea to treat unknown options as fatal.)

timbunce commented 8 years ago

Ha. Success. It was a copy-n-paste typo, I'd used ----loader-option :) This is working now, so I'm happy to close the issue. Thanks!