Skip Menu |

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

Report information
The Basics
Id: 67225
Status: stalled
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: frogomatic [...] gmail.com
Cc:
AdminCc:

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



Subject: Need ability to add indexes without foreign key constraints
We're using DBIx in particular DBIx::Class::Schema to automagically construct our SQL. We'd like to be able to add indexes to fields generally, and in particular, be able to have foreign key references, with indexes for performance, but without constraints. For example we have __PACKAGE__-->belongs_to(...., { "foo.id" => "self.foo_id"}, { is_foreign_key_constraint => 0 } ); where 'foo_id' might be null, and/or rows in 'foo' might be deleted WITHOUT removing rows in 'self'. I'd like to be able to add an option like { do_index=> 1 } and get SQL code to make an index, without adding the foreign key constraint which is causing problems when rows in Any chance of this getting implemented?
On Mon Apr 04 12:50:29 2011, frogomatic wrote: Show quoted text
> We're using DBIx in particular DBIx::Class::Schema to automagically > construct our SQL. We'd like to be able to add indexes to fields > generally, and in particular, be able to have foreign key references, > with indexes for performance, but without constraints. > > For example we have > > __PACKAGE__-->belongs_to(...., { "foo.id" => "self.foo_id"}, > { is_foreign_key_constraint => 0 } ); > > where 'foo_id' might be null, and/or rows in 'foo' might be deleted > WITHOUT removing rows in 'self'. I'd like to be able to add an option > like { do_index=> 1 } and get SQL code to make an index, without adding > the foreign key constraint which is causing problems when rows in > > Any chance of this getting implemented?
Sorry for the late reply. Certainly something like this could be implemented (even though it seems of little utility to me personally). All you need to do is make some minimal changes to SQL::Translator::Parser::DBIx::Class and make it understand a combination of the following already defined relationship attributes: {... is_foreign_key_constraint => 0, add_fk_index => 1 ... } (attributes are listed here: http://search.cpan.org/~ribasushi/DBIx-Class/lib/DBIx/Class/Relationship/Base.pm#attributes) The code modification itself is trivial, the test should not be very complex either - just look at t/99dbic_sqlt_parser.t. If you send me a patch along these lines I have no problem with applying it. Cheers!
Just marking this as 'stalled', until someone finds the tuits to implement this.