Skip Menu |

This queue is for tickets about the SQL-Translator CPAN distribution.

Report information
The Basics
Id: 36825
Status: resolved
Priority: 0/
Queue: SQL-Translator

People
Owner: Nobody in particular
Requestors: jasonk@cpan.org (no email address)
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.09000
Fixed in: 0.09002



Subject: PostgreSQL producer ignores views... (PATCH)
Patch attached... -- www.jasonkohles.com
Subject: postgresql-view.patch
Index: PostgreSQL.pm =================================================================== --- PostgreSQL.pm (revision 1377) +++ PostgreSQL.pm (working copy) @@ -208,12 +208,20 @@ } + my @views = map { create_view( $_ ) } $schema->get_views; + $output = join("\n\n", @table_defs); if ( @fks ) { $output .= "--\n-- Foreign Key Definitions\n--\n\n" unless $no_comments; $output .= join( "\n\n", @fks ) . "\n"; } + if ( @views ) { + $output .= "--\n-- View Definitions\n--\n\n" unless $no_comments; + $output .= join( "\n\n", @views )."\n"; + } + + if ( $WARN ) { if ( %truncated ) { warn "Truncated " . keys( %truncated ) . " names:\n"; @@ -741,6 +749,15 @@ return $out; } +sub create_view { + my $view = shift; + + ( my $sql = $view->sql ) =~ s/^/ /gm; + + return sprintf( "CREATE VIEW %s AS\n%s;", $view->name, $sql ); +} + + 1; # -------------------------------------------------------------------
A more elaborate version of your patch has been merged about 3 years ago. Cheers!