From: Peter Rabbitson Date: Wed, 2 Jun 2010 12:14:04 +0000 (+0000) Subject: Auto-fill rdbms version for sqlt X-Git-Tag: v0.08122~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=96736321fa6fb1efc9e471b037e508778188dbbe;p=dbsrgits%2FDBIx-Class.git Auto-fill rdbms version for sqlt --- diff --git a/Changes b/Changes index 0dd68f8..2d8c38e 100644 --- a/Changes +++ b/Changes @@ -29,6 +29,8 @@ Revision history for DBIx::Class using software limit emulation - create_ddl_dir (and derivatives) now attempt to create the given $ddl_dir if it does not already exist + - deployment_statements now automatically supplies the current RDBMS + version to SQLT producer_args for MySQL, Pg, SQLite and Oracle * Fixes - Fix nasty potentially data-eating bug when deleting/updating diff --git a/lib/DBIx/Class/Manual/Troubleshooting.pod b/lib/DBIx/Class/Manual/Troubleshooting.pod index 18fb89e..820359d 100644 --- a/lib/DBIx/Class/Manual/Troubleshooting.pod +++ b/lib/DBIx/Class/Manual/Troubleshooting.pod @@ -158,13 +158,5 @@ can grow very large. The solution is to use the smallest practical value for LongReadLen. -=head2 create_ddl_dir does not produce DDL for MySQL views - -L does not create DDL for MySQL views if it doesn't know you -are using mysql version 5.000001 or higher. To explicity set this version, add -C to the C in the C<%sqlt> options. - - $schema->create_ddl_dir(['MySQL'], '1.0', './sql/', undef, { producer_args => { mysql_version => 5.000058 } }) - =cut diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index 0a7294d..1c3157c 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -88,9 +88,13 @@ sub deployment_statements { $sqltargs->{quote_table_names} = $quote_char ? 1 : 0; $sqltargs->{quote_field_names} = $quote_char ? 1 : 0; - my $oracle_version = try { $self->_get_dbh->get_info(18) }; - - $sqltargs->{producer_args}{oracle_version} = $oracle_version; + if ( + ! exists $sqltargs->{producer_args}{oracle_version} + and + my $dver = $self->_server_info->{dbms_version} + ) { + $sqltargs->{producer_args}{oracle_version} = $dver; + } $self->next::method($schema, $type, $version, $dir, $sqltargs, @rest); } diff --git a/lib/DBIx/Class/Storage/DBI/Pg.pm b/lib/DBIx/Class/Storage/DBI/Pg.pm index d1e8e1e..fd604d9 100644 --- a/lib/DBIx/Class/Storage/DBI/Pg.pm +++ b/lib/DBIx/Class/Storage/DBI/Pg.pm @@ -205,8 +205,12 @@ sub deployment_statements { $sqltargs ||= {}; - if (my $version = $self->_server_info->{dbms_version}) { - $sqltargs->{producer_args}{postgres_version} = $version; + if ( + ! exists $sqltargs->{producer_args}{postgres_version} + and + my $dver = $self->_server_info->{normalized_dbms_version} + ) { + $sqltargs->{producer_args}{postgres_version} = $dver; } $self->next::method($schema, $type, $version, $dir, $sqltargs, @rest); diff --git a/lib/DBIx/Class/Storage/DBI/SQLite.pm b/lib/DBIx/Class/Storage/DBI/SQLite.pm index 4a95dbf..bffd133 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLite.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLite.pm @@ -45,13 +45,17 @@ sub backup } sub deployment_statements { - my $self = shift;; + my $self = shift; my ($schema, $type, $version, $dir, $sqltargs, @rest) = @_; $sqltargs ||= {}; - if (my $version = $self->_server_info->{dbms_version}) { - $sqltargs->{producer_args}{sqlite_version} = $version; + if ( + ! exists $sqltargs->{producer_args}{sqlite_version} + and + my $dver = $self->_server_info->{normalized_dbms_version} + ) { + $sqltargs->{producer_args}{sqlite_version} = $dver; } $self->next::method($schema, $type, $version, $dir, $sqltargs, @rest); diff --git a/lib/DBIx/Class/Storage/DBI/mysql.pm b/lib/DBIx/Class/Storage/DBI/mysql.pm index ecdc29a..7d80187 100644 --- a/lib/DBIx/Class/Storage/DBI/mysql.pm +++ b/lib/DBIx/Class/Storage/DBI/mysql.pm @@ -51,6 +51,23 @@ sub sqlt_type { return 'MySQL'; } +sub deployment_statements { + my $self = shift; + my ($schema, $type, $version, $dir, $sqltargs, @rest) = @_; + + $sqltargs ||= {}; + + if ( + ! exists $sqltargs->{producer_args}{mysql_version} + and + my $dver = $self->_server_info->{normalized_dbms_version} + ) { + $sqltargs->{producer_args}{mysql_version} = $dver; + } + + $self->next::method($schema, $type, $version, $dir, $sqltargs, @rest); +} + sub _svp_begin { my ($self, $name) = @_;