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
yamltodb drops database-wide objects when using a schema list #21
Comments
Currently yamltodb attempts to drop the database-wide objects when using a schema list, even if they are defined in the yaml input file |
I agree that yamltodb -n shouldn't be dropping database-wide objects such as casts and languages. However, I don't think dbtoyaml -n should exclude such database-wide objects, since the dbtoyaml output would then be incomplete, e.g., a function in the selected schema may be using the language in question, or a view in that schema may use a cast. |
Could you please try the following fix: diff --git a/pyrseas/database.py b/pyrseas/database.py
index 03d314f..3b86ee4 100644
--- a/pyrseas/database.py
+++ b/pyrseas/database.py
@@ -106,6 +106,9 @@ class Database(object):
for sch in self.db.schemas.keys():
if sch not in schemas:
del self.db.schemas[sch]
+ # exclude database-wide objects
+ self.db.languages = LanguageDict()
+ self.db.casts = CastDict()
def from_catalog(self):
"""Populate the database objects by querying the catalogs |
Misunderstood cause of problem in #27. |
I have a database with some schemas in it. Some of them (postgis) create user-defined CAST functions. I also have the plpythonu language installed.
I have a yaml file that defines a new schema and I want to add the new schema without affecting the other schemas in the database so I run:
This gives me the CREATE SCHEMA, CREATE TABLE, etc. that I am expecting to create the new schema, but it also gives:
I think that when yamltodb is run with a schema list parameter it should ignore objects defined at the database-wide level.
In order for round-tripping to work as expected I would also expect dbtoyaml not to include database-wide objects when running with a schema list parameter.
The text was updated successfully, but these errors were encountered: