Using the latest sqlobject 7.0 tg-admin sql sql fails. The example is TurboTunes model.py
The produced SQL output is:
CREATE TABLE album (
id SERIAL PRIMARY KEY,
name VARCHAR(200),
artist_id INT, CONSTRAINT artist_id_exists FOREIGN KEY (artist_id) REFERENCES artist (id)
);
CREATE TABLE artist (
id SERIAL PRIMARY KEY,
name VARCHAR(200)
)
CREATE TABLE artist_genre (
artist_id INT NOT NULL,
genre_id INT NOT NULL
);
CREATE TABLE genre (
id SERIAL PRIMARY KEY,
name VARCHAR(200)
);
CREATE TABLE song (
id SERIAL PRIMARY KEY,
name VARCHAR(200),
album_id INT, CONSTRAINT album_id_exists FOREIGN KEY (album_id) REFERENCES album (id)
);
Trying to run this leads to:
psql:part.sql:5: NOTICE: CREATE TABLE will create implicit sequence "album_id_seq" for "serial" column "album.id"
psql:part.sql:5: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "album_pkey" for table "album"
psql:part.sql:5: ERROR: relation "artist" does not exist
psql:part.sql:14: ERROR: syntax error at or near "CREATE" at character 74
psql:part.sql:19: NOTICE: CREATE TABLE will create implicit sequence "genre_id_seq" for "serial" column "genre.id"
psql:part.sql:19: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "genre_pkey" for table "genre"
CREATE TABLE
psql:part.sql:25: NOTICE: CREATE TABLE will create implicit sequence "song_id_seq" for "serial" column "song.id"
psql:part.sql:25: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "song_pkey" for table "song"
psql:part.sql:25: ERROR: relation "album" does not exist
But it should be
CREATE TABLE genre (
id SERIAL PRIMARY KEY,
name VARCHAR(200)
);
CREATE TABLE artist (
id SERIAL PRIMARY KEY,
name VARCHAR(200)
);
CREATE TABLE album (
id SERIAL PRIMARY KEY,
name VARCHAR(200),
artist_id INT, CONSTRAINT artist_id_exists FOREIGN KEY (artist_id) REFERENCES artist (id)
);
CREATE TABLE artist_genre (
artist_id INT NOT NULL,
genre_id INT NOT NULL
);
CREATE TABLE song (
id SERIAL PRIMARY KEY,
name VARCHAR(200),
album_id INT, CONSTRAINT album_id_exists FOREIGN KEY (album_id) REFERENCES album (id)
);
Which results in:
psql:part.sql:4: NOTICE: CREATE TABLE will create implicit sequence "artist_id_seq" for "serial" column "artist.id"
psql:part.sql:4: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "artist_pkey" for table "artist"
CREATE TABLE
psql:part.sql:9: NOTICE: CREATE TABLE will create implicit sequence "genre_id_seq" for "serial" column "genre.id"
psql:part.sql:9: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "genre_pkey" for table "genre"
CREATE TABLE
psql:part.sql:15: NOTICE: CREATE TABLE will create implicit sequence "album_id_seq" for "serial" column "album.id"
psql:part.sql:15: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "album_pkey" for table "album"
CREATE TABLE
CREATE TABLE
psql:part.sql:27: NOTICE: CREATE TABLE will create implicit sequence "song_id_seq" for "serial" column "song.id"
psql:part.sql:27: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "song_pkey" for table "song"
CREATE TABLE