On Thu, Dec 14, 2017 at 10:40 PM, Jonathan Schultz <[email protected]> wrote:
>
> Hello,
>
> Using SQLAlchemy for the first time in some while I am having trouble doing
> reflection on certain tables in an SQL Anywhere database (created by closed
> source third party software NVivo, so no chance of reverse engineering the
> code that created it):
>
> sqlalchemy.exc.ArgumentError: ForeignKeyConstraint with duplicate source
> column references are not supported.
>
> around line 2863 in schema.py (this is release 1.1.11, the first where the
> error occurs), which tests that the list 'columns' does not contain
> duplicate items. Putting some debug statements I see that the variable
> 'columns' has the value:
>
> ['Item_Id', 'CompoundSourceRegion_Id', 'Item_Id', 'CompoundSourceRegion_Id']
>
> ie it certainly does contain duplicates. However examining the table in
> question I see no evidence of duplicate source column references in the
> offending table. Here is an extract of the exported DDL containing all the
> foreign key definitions for the offending table:
>
> ALTER TABLE test.wiwalisataob2aaf.Annotation
>     ADD FOREIGN KEY (Item_Id)
>     REFERENCES Item (Id);
>
> ALTER TABLE test.wiwalisataob2aaf.Annotation
>     ADD FOREIGN KEY (CreatedBy,ModifiedBy)
>     REFERENCES UserProfile (Id,Id);
>
> ALTER TABLE test.wiwalisataob2aaf.Annotation
>     ADD FOREIGN KEY (CompoundSourceRegion_Id,Item_Id)
>     REFERENCES CompoundSourceRegion (Id,Item_Id);
>
> With my limited knowledge I'd say that there is a bug here somewhere. I
> suspect that it is in sqlalechemy-sqlany, given that the Windows version of
> the same NVivo software creates a MSSQL server database with an almost
> identical structure that SQLAlchemy handles without a problem). But where to
> look next... can anyone offer a suggestion?

this is a bug in sqlalchemy-sqlany and you should report it over there.

Basically it's running a query to get at the foreign key constraints
in your tables and this query, or how its results are handled, are
incorrect in some way.  E.g. somewhere here:
https://github.com/sqlanywhere/sqlalchemy-sqlany/blob/master/sqlalchemy_sqlany/base.py#L571

I think this assertion in SQLAlchemy was added somewhat recently and
is local to the 1.1 series, so if you need things to "just work" for
the moment you can try a 1.0 SQLAlchemy release which is likely the
last version that sqlany was tested against as it looks unchanged for
two years.



>
> Many thanks in advance.
>
> Jonathan
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to