Giter Club home page Giter Club logo

sqlalchemy-diff's People

Contributors

charness avatar erikced avatar gianchub avatar juliotrigo avatar kooba avatar mattbennett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sqlalchemy-diff's Issues

Produce diffs only from metadata

I'd like to use this library to test database migrations, please tell me if something like this is possible:

from sqlalchemy-diff import compare
def test_migrations_round_trip(db:SQLalchemy):
    old_metadata = copy(db.metadata)
    new_db = revert_migration(new_migration(db))
    new_metadata = new_db.metadata
    assert compare(old_metadata,new_metadata).is_match

Release v0.1.4 to PyPI

The latest version on PyPI is v0.1.3, which is missing features like constraint diffing. Would it be possible to release v0.1.4 to PyPI?

_process_type should call the compile of the dialect

Hi, I'm using sqlalchemy-diff with pybigquery, and it seems sqlalchemy-diff is having issues when attempting to process custom types, like an array, I get this error:

 File "/env/lib/python3.7/site-packages/sqlalchemydiff/comparer.py", line 349, in _process_types
    column_dict[column]['type'])
  File "/env/lib/python3.7/site-packages/sqlalchemydiff/comparer.py", line 359, in _process_type
    return type_.compile()
  File "/env/lib/python3.7/site-packages/sqlalchemy/sql/type_api.py", line 580, in compile
    return dialect.type_compiler.process(self)
  File "/env/lib/python3.7/site-packages/sqlalchemy/sql/compiler.py", line 400, in process
    return type_._compiler_dispatch(self, **kw)
  File "/env/lib/python3.7/site-packages/sqlalchemy/sql/visitors.py", line 89, in _compiler_dispatch
    raise exc.UnsupportedCompilationError(visitor, cls)
sqlalchemy.exc.UnsupportedCompilationError: Compiler <sqlalchemy.sql.compiler.GenericTypeCompiler object at 0x7f932a51ffd0> can't render element of type <class 'sqlalchemy.sql.sqltypes.ARRAY'> (Background on this error at: http://sqlalche.me/e/l7de)

which comes from the fact that, [I assume], _process_type is calling the default compiler and not the one from the dialect

Allow optional aliases for 'left' and 'right'

It would be nice to have the output in result.errors have aliases substituted for 'left' and 'right'

Something like,

result = compare(left_uri, right_uri, left_alias='alpha_db', right_alias='omega_db')

This would be really useful in the unit tests I'm writing so failures in the results would indicate which db is which

ability to ignore default instead of column?

Hi ,

I was wondering if it is possible to only exclude default value for a given column for comparing, for instance i want to ignore server_default and default attribute that is returned by diff dictionary

Intermittent failures in destroy_database()

We're using alembic-verify and sqlalchemy-diff to verify the correctness of our migrations on a PostgreSQL database, but every now and then the destroy_database(temporary_uri) call in the test's teardown fails with the following error:

(psycopg2.ProgrammingError) must be a member of the role whose process is being terminated

The database is created in the test's setup so nothing outside of the test should know that it exists, and it's only used for a single test. Do you have any ideas on what could be wrong?

Full stacktrace:

File "/usr/lib/python3.5/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/usr/lib/python3.5/unittest/case.py", line 603, in run
    self.tearDown()
  File ".venv/lib/python3.5/site-packages/nose/case.py", line 385, in tearDown
    try_run(self.inst, ('teardown', 'tearDown'))
  File ".venv/lib/python3.5/site-packages/nose/util.py", line 471, in try_run
    return func()
  File "migration/tests/test_upgrade_downgrade.py", line 28, in teardown
    destroy_database(self.database_uri)
  File ".venv/lib/python3.5/site-packages/sqlalchemydiff/util.py", line 83, in destroy_database
    drop_database(uri)
  File ".venv/lib/python3.5/site-packages/sqlalchemy_utils/functions/database.py", line 603, in drop_database
    connection.execute(text)
  File ".venv/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 906, in execute
    return self._execute_text(object, multiparams, params)
  File ".venv/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1054, in _execute_text
    statement, parameters
  File ".venv/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
    context)
  File ".venv/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
    exc_info
  File ".venv/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 189, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=exc_value)
  File ".venv/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 182, in reraise
    raise value.with_traceback(tb)
  File ".venv/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File ".venv/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute
    cursor.execute(statement, parameters)
(psycopg2.ProgrammingError) must be a member of the role whose process is being terminated
 [SQL: "\n        SELECT pg_terminate_backend(pg_stat_activity.pid)\n        FROM pg_stat_activity\n        WHERE pg_stat_activity.datname = 'temp_29aa5e9b372342c2a1d0de1bf24fedfb'\n          AND pid <> pg_backend_pid();\n        "]

Pass table type information to the diff

Postgres has table types .relkind in pg_tables that are necessary to identify whether the difference is in a table or in the partitions (as the query lists all tables and partitions).

To be able to ignore differences on partitions, it would be useful to be able to see which table type each table on each side is made of.

Suggestion: have the diff contain table types

Produce correct diff for unnamed foreign keys

Currently, foreign keys are diffed by sticking all foreign keys into a dict indexed by name. However, there may be multiple foreign keys with no name, in which case only one of them will be included in the dict.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.