Skip Menu |

This queue is for tickets about the DBIx-Class-Schema-Loader CPAN distribution.

Report information
The Basics
Id: 20748
Status: rejected
Priority: 0/
Queue: DBIx-Class-Schema-Loader

People
Owner: blblack [...] gmail.com
Requestors: bitcard [...] sveneppler.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Does not create bleongs_to() relations properly
Perl: ActiveState Perl v5.8.8 DBIx-Class-Schema-Loader Version: 0.03007 OS: Windows 2000 SP4 I'm trying to automaticly load the attaches database schema with DBIx::Class::Schema::Loader. But the loader doesn't create the relations between the tables which only refer with an ForeingKey to geodb_locations. It gives out a warning, that for example geodb_type_names has no primary key. Which is true. But it referes with a foreign key to the table geodb_locations which has loc_id set as primary. Therefor the loader should create a belongs_to() relation in the DBIC::Schema it creates. But it doesn't. The database dump can be obtained from opengeodb.sf.net.
Subject: db.png
Download db.png
image/png 20.6k
db.png
From: bitcard [...] sveneppler.de
On Fr. 28. Jul. 2006, 16:12:11, ghandi wrote: Show quoted text
> Perl: ActiveState Perl v5.8.8 > DBIx-Class-Schema-Loader Version: 0.03007 > OS: Windows 2000 SP4 > > I'm trying to automaticly load the attaches database schema with > DBIx::Class::Schema::Loader. But the loader doesn't create the > relations between the tables which only refer with an ForeingKey to > geodb_locations. It gives out a warning, that for example > geodb_type_names has no primary key. Which is true. But it referes
with Show quoted text
> a foreign key to the table geodb_locations which has loc_id set as > primary. > > Therefor the loader should create a belongs_to() relation in the > DBIC::Schema it creates. But it doesn't. > > The database dump can be obtained from opengeodb.sf.net.
Sorry, i just copy-pasted an table name for the example. But of course "geodb_type_names" has no primary key but it's not even related to geodb_locations. I mean a table like "geodb_intdata" where the loader complains about the primary key.
This is actually a problem with either MySQL itself or the OpenGeoDB datafile for MySQL, depending on which way you look at it, but I can't fix it here in DBIx::Class::Schema::Loader. The root of the problem is that the tables with FKs in questions are created like: CREATE TABLE foo ( some_col INTEGER REFERENCES geodb_location(loc_id) ... ) Engine=InnoDB; And they need to be created as: CREATE TABLE foo ( some_col INTEGER, ... FOREIGN KEY (some_col) REFERENCES geodb_locations(loc_id) ) Engine=InnoDB; The first form parses correctly in mysql, but the REFERENCES statement is silently ignored (I'd be shocked, but I've come to expect this kind of behavior from them). The second form actually creates a foreign key constraint in mysql. Other databases (like PostgreSQL) don't have this issue and accept either form just fine. You can tell the difference by using the command "SHOW CREATE TABLE foo" afterwards. The one created the second way shows a constraint, the first does not. DBIx::Class::Schema::Loader is only capable of loading what the database knows about. If the DB ignored your request for an FK constraint, so will Loader.