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

Another reflection regression #70

Closed
berdario opened this Issue Dec 4, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@berdario
Contributor

berdario commented Dec 4, 2015

Sorry, I should've tested this earlier as soon as you finished working on #64 , but I kept using 0.1.2 and didn't check if there were any more issues.

The issue now is with tables that have foreign keys contraints, I've been able to reproduce the problem with the following 2 tables:

create table ref.foo(id integer identity(1, 1) not null unique);

create table ref.bar(
foo_id integer not null,
foreign key(foo_id) references ref.foo(id))

And, when running .reflect(only=['bar'], schema='ref')

I get *** AttributeError: 'NoneType' object has no attribute 'group'

This is the traceback:

  File "/home/dario/Projects/l2/Hydra/database/hydra_database/__init__.py", line 81, in cached_metadatas
    redshiftmeta.reflect(only=tablenames, schema=schema)
  File "/home/dario/.local/share/virtualenvs/hydra_worker/local/lib/python2.7/site-packages/sqlalchemy/sql/schema.py", line 3647, in reflect
    Table(name, self, **reflect_opts)
  File "/home/dario/.local/share/virtualenvs/hydra_worker/local/lib/python2.7/site-packages/sqlalchemy/sql/schema.py", line 416, in __new__
    metadata._remove_table(name, schema)
  File "/home/dario/.local/share/virtualenvs/hydra_worker/local/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/home/dario/.local/share/virtualenvs/hydra_worker/local/lib/python2.7/site-packages/sqlalchemy/sql/schema.py", line 411, in __new__
    table._init(name, metadata, *args, **kw)
  File "/home/dario/.local/share/virtualenvs/hydra_worker/local/lib/python2.7/site-packages/sqlalchemy/sql/schema.py", line 484, in _init
    self._autoload(metadata, autoload_with, include_columns)
  File "/home/dario/.local/share/virtualenvs/hydra_worker/local/lib/python2.7/site-packages/sqlalchemy/sql/schema.py", line 496, in _autoload
    self, include_columns, exclude_columns
  File "/home/dario/.local/share/virtualenvs/hydra_worker/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1477, in run_callable
    return callable_(self, *args, **kwargs)
  File "/home/dario/.local/share/virtualenvs/hydra_worker/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 364, in reflecttable
    return insp.reflecttable(table, include_columns, exclude_columns)
  File "/home/dario/.local/share/virtualenvs/hydra_worker/local/lib/python2.7/site-packages/sqlalchemy/engine/reflection.py", line 578, in reflecttable
    exclude_columns, reflection_options)
  File "/home/dario/.local/share/virtualenvs/hydra_worker/local/lib/python2.7/site-packages/sqlalchemy/engine/reflection.py", line 666, in _reflect_fk
    table_name, schema, **table.dialect_kwargs)
  File "/home/dario/.local/share/virtualenvs/hydra_worker/local/lib/python2.7/site-packages/sqlalchemy/engine/reflection.py", line 447, in get_foreign_keys
    **kw)
  File "<string>", line 2, in get_foreign_keys
  File "/home/dario/.local/share/virtualenvs/hydra_worker/local/lib/python2.7/site-packages/sqlalchemy/engine/reflection.py", line 54, in cache
    ret = fn(self, con, *args, **kw)
  File "/home/dario/.local/share/virtualenvs/hydra_worker/local/lib/python2.7/site-packages/sqlalchemy_redshift/dialect.py", line 396, in get_foreign_keys
    referred_column = m.group('referred_column')
AttributeError: 'NoneType' object has no attribute 'group'

graingert added a commit that referenced this issue Dec 5, 2015

@graingert graingert closed this in cd4e03e Dec 6, 2015

graingert added a commit that referenced this issue Dec 6, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment