Giter Site home page Giter Site logo

Comments (5)

steve-federowicz avatar steve-federowicz commented on September 4, 2024

Awesome!! Thanks Pierre.

Assigning @jslu9 as this could be critical for BiGG and he has the closest familiarity with that code.

@jslu9 we could probably also use this to develop a test case to make sure we don't get similar issues in other areas of the code.

Thanks Pierre!

from cobradb.

psalvy avatar psalvy commented on September 4, 2024

My pleasure ! I'm sorry, I did not know about this get_or_create function, thanks for showing it to me !
I'll keep you updated if I find new stuff.

Pierre

EDIT:
I think I kinow why the unique constraint is not enforced: it is not declared as a table_args, but placed 'naked' in the column declaration. As we are using the declarative mode of SQLAlchemy, the line

    UniqueConstraint('compartment_id', 'component_id')

should be replaced by:

    __table_args__ = (
        UniqueConstraint('compartment_id', 'component_id'),
        {})

EDIT2: This goes also for the classes:

Model
ModelReaction
ReactionMatrix

in models.py that have the same problem

from cobradb.

jslu9 avatar jslu9 commented on September 4, 2024

Ok, I'm looking into it. It's strange that the unique constraint is not
being enforced by sqlalchemy. I'm going to put the unique constraints into
the table args and see if it configures the table correctly that way.

On Mon, Nov 3, 2014 at 11:32 AM, Pierre SALVY [email protected]
wrote:

My pleasure ! I'm sorry, I did not know about this get_or_create function,
thanks for showing it to me !
I'll keep you updated if I find new stuff.

Pierre


Reply to this email directly or view it on GitHub
#9 (comment).

from cobradb.

psalvy avatar psalvy commented on September 4, 2024

Also, in the declaration of the Model class, as follows:

class Model(Base):
    __tablename__='model'
    id = Column(Integer, Sequence('wids'), primary_key=True)
    bigg_id = Column(String)
    first_created = Column(DateTime)
    genome_id = Column(Integer, ForeignKey('genome.id'))
    genome = relationship('Genome', backref='model')
    UniqueConstraint('name', 'firstcreated')
    notes = Column(String)
    __table_args__ = (UniqueConstraint('bigg_id'),{})
    def __repr__(self):
        return "Model (#%d) %s %s" % (self.id, self.bigg_id, self.first_created)

I noticed a double declaration of the UniqueConstraint, one of which is invalid according to what I posted above, and I also noticed that they do not ask for the same uniqueness.

from cobradb.

zakandrewking avatar zakandrewking commented on September 4, 2024

@jslu9 Is this still happening?

from cobradb.

Related Issues (14)

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.