unalloc / sqlautocode

Automatically exported from code.google.com/p/sqlautocode
Other
0 stars 0 forks source link

sqlautocode generates foreign keys but not relation information #31

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. With attached sql create a MySQL db
2. run sqlautocode -d mysql://localhost/dbname -o model.py

What is the expected output? What do you see instead?
Expected: generated relation definitions 
Instead got:
samples = Table(u'samples', metadata,
    Column(u'id', SMALLINT(), primary_key=True, nullable=False),
    Column(u'name', VARCHAR(length=45, convert_unicode=False, assert_unicode=None, unicode_error=None, _warn_on_bytestring=False), nullable=False),
    Column(u'experiment_id', SMALLINT(), ForeignKey('experiments.id'), nullable=False),
    Column(u'timepoint_id', SMALLINT(), ForeignKey('timepoints.id'), nullable=False),
)

samples2conditions = Table(u'samples2conditions', metadata,
    Column(u'condition_id', SMALLINT(), ForeignKey('conditions.id'), primary_key=True, nullable=False),
    Column(u'sample_id', SMALLINT(), ForeignKey('samples.id'), primary_key=True, nullable=False),
)

class Condition(DeclarativeBase):
    __tablename__ = 'conditions'

    #column definitions
    experiment_id = Column(u'experiment_id', SMALLINT(), ForeignKey('experiments.id'), nullable=False)
    id = Column(u'id', SMALLINT(), primary_key=True, nullable=False)
    name = Column(u'name', VARCHAR(length=45, convert_unicode=False, assert_unicode=None, unicode_error=None, _warn_on_bytestring=False), nullable=False)

    #relation definitions

class Experiment(DeclarativeBase):
    __tablename__ = 'experiments'

    #column definitions
    id = Column(u'id', SMALLINT(), primary_key=True, nullable=False)
    name = Column(u'name', VARCHAR(length=45, convert_unicode=False, assert_unicode=None, unicode_error=None, _warn_on_bytestring=False), nullable=False)

    #relation definitions

class Sample(DeclarativeBase):
    __table__ = samples

    #relation definitions

class Timepoint(DeclarativeBase):
    __tablename__ = 'timepoints'

    #column definitions
    experiment_id = Column(u'experiment_id', SMALLINT(), ForeignKey('experiments.id'), nullable=False)
    id = Column(u'id', SMALLINT(), primary_key=True, nullable=False)
    name = Column(u'name', VARCHAR(length=45, convert_unicode=False, assert_unicode=None, unicode_error=None, _warn_on_bytestring=False), nullable=False)

    #relation definitions

What version of the product are you using? On what operating system?
* MySQL 5.1.47
* archlinux
* sqlautocode 0.6b1 (with issue27 patch)
* sqlalchemy 0.6.5
* python 2.7

Anyone any clue why these don't show up?

Kenny

Original issue reported on code.google.com by kennybil...@gmail.com on 10 Jan 2011 at 3:56

GoogleCodeExporter commented 8 years ago
Of course, forgot to attach the sql.

Original comment by kennybil...@gmail.com on 10 Jan 2011 at 3:56

Attachments:

GoogleCodeExporter commented 8 years ago
Damn, and I meant with issue29 patch!

Original comment by kennybil...@gmail.com on 10 Jan 2011 at 3:58

GoogleCodeExporter commented 8 years ago
I observe the same problem with issue29 and issue39 patches.

Original comment by loni...@gmail.com on 23 Nov 2012 at 3:55

GoogleCodeExporter commented 8 years ago
I'm also having the same issue using 
* MySQL 5.1.67
* sqlautocode 0.6b1 (with  issue41  patch)
* sqlalchemy 0.8.1
* python 2.6

Original comment by ksi...@ksindi.com on 1 Jul 2013 at 8:30

GoogleCodeExporter commented 8 years ago
The problem I observed is that, if there is one table that can't get relations 
generated, then ALL the table relation generations fail. The table that gave me 
a problem had overlapping composite foreign keys. I was able to generate all 
relations once I excluded that table for the table generation. I don't know how 
to fix.

Original comment by ksi...@ksindi.com on 3 Jul 2013 at 5:35