DBIx-Class

Z mj41.cz

My Patch for SQL::Translator::Producer::DBIx::Class::File

  • add {join_type => 'left'} to belongs_to for is_nullable columns

Submited as part of TapTinder:

Revision: 147
Author: mj41
Date: 19:34:04, 23. prosince 2008
Message:
* SQL::Translator::Producer::DBIx::Class::File
** add {join_type => 'left'} to belongs_to for is_nullable columns
----
Modified : /trunk/server/libcpan/SQL/Translator/Producer/DBIx/Class/File.pm


Index: File.pm
===================================================================
--- File.pm	(revision 146)
+++ File.pm	(revision 147)
@@ -124,10 +124,20 @@
 #                     $cont->fields->[0]->name . "', '" .
 #                     "${dbixschema}::" . $cont->reference_table . "');\n";
 
+                my $join_part = '';
+                my $field_name = $cont->fields->[0]->name;
+
+                if ( $table->get_field($field_name)->is_nullable ) {
+                    $join_part = qq/,{join_type => 'left'}/;
+                }
+#                print Data::Dumper::Dumper( \@{$cont->reference_fields} );
                 $tableextras{$table->name} .= "\n__PACKAGE__->belongs_to('" .
-                    $cont->fields->[0]->name . "', '" .
-                    "${dbixschema}::" . $cont->reference_table . "');\n";
-                
+                    $field_name . "',"
+                    . "'${dbixschema}::" . $cont->reference_table . "'"
+                    . ",'" . $field_name . "'"
+                    . $join_part
+                    . ");\n";
+
                 my $other = "\n__PACKAGE__->has_many('" .
                     "get_" . $table->name. "', '" .
                     "${dbixschema}::" . $table->name. "', '" .
spřízněné weby
Jazyk