OpenEnergyPlatform / oedialect

Repository for an SQLAlchemy dialect using the OEP's REST-API
GNU Affero General Public License v3.0
2 stars 3 forks source link

Bug reflecting unique constraints #36

Open henhuy opened 4 years ago

henhuy commented 4 years ago

I'm trying to use saio for autodetecting sqlalchemy models via oedialect. I already stumbled upon #35 -but could fix it by setting SQLalchemy to 1.3.14 as suggested in the answer. Unfortunately, i got KeyError: 'column_names' in function _reflect_unique_constraints from sqlalchemy.engine.reflection module. It might come from different definitions of the unique constraints in oedialect and sqlalchemy? The thing is, that I never set a unique constraint, but my foreign key is handled returned when calling get_unique_constraints: {'name': 'oed_data_scenario_id_fkey', 'constrained_columns': ['scenario_id'], 'referred_schema': 'model_draft', 'referred_table': 'oed_scenario', 'referred_columns': ['id'], 'options': {'onupdate': None, 'ondelete': None, 'deferrable': None, 'initially': None, 'match': None}} So either, there should be any unique constraint at all, or the unqiue constraint return data has to be fixed in order to work with reflect module of sqlalchemy... What do you think, @MGlauer ?

henhuy commented 3 years ago

This is my code:

import saio
from oem2orm.oep_oedialect_oem2orm import setup_db_connection

engine, meta = setup_db_connection()

saio.register_schema("model_draft", engine)
from saio.model_draft import Base
from saio.model_draft import oed_scenario, oed_scalar
MGlauer commented 3 years ago

Isn't this fixed with PR #37?

jh-RLI commented 3 years ago

Not fixed by #37 the same error persists.