Skip to content

No foreign key definition in the database but got ForeignKeyConstraint with duplicate source column references are not supported error. #527

Description

@HuiyanRoy

I setup the environment and ran

curl -X 'POST' '127.0.0.1/api/v1/database-connections' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{ "alias": "db2z-dwydd1d", "connection_uri": "db2+my_db://name:password@ip_address:port/location", "schemas": ["SAMPLE"]  }'

and got error
{"error_code":"invalid_database_connection","message":"ForeignKeyConstraint with duplicate source column references are not supported.","description":null,"detail":{"alias":"db2z-location","use_ssh":false,"connection_uri":"gAAAAABn7SrtUowgxLEScFD_QMxxxxxx==","schemas":null,"path_to_credentials_file":null,"llm_api_key":null,"ssh_settings":null,"file_storage":null}}%

In my database SAMPLE, I do not have foreign key definitions.

The mentioned error seems to have been thrown by sqlalchemy, the scan_single_table function

 try:
                MetaData.reflect(meta, views=True, schema=table.schema_name)
                self.scan_single_table(
                    meta=meta,
                    table=table.table_name,
                    db_engine=db_engine,
                    db_connection_id=table.db_connection_id,
                    repository=repository,
                    scanner_service=scanner_service,
                    schema=table.schema_name,
                )
            except Exception as e:
                logger.error(e, exc_info=True)
                repository.save_table_info(
                    TableDescription(
                        db_connection_id=table.db_connection_id,
                        table_name=table.table_name,
                        status=TableDescriptionStatus.FAILED.value,
                        error_message=f"{e}",
                        schema_name=table.schema_name,
                    )
                )

Any plan to fix this?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions