[Bps-public-commit] dbix-searchbuilder branch, master, updated. 1.60-15-gcb392b1
Ruslan Zakirov
ruz at bestpractical.com
Thu Sep 15 12:01:52 EDT 2011
The branch, master has been updated
via cb392b12b389b72ebff8562ccda632ba4e1d5aaf (commit)
via 8e4478b0ad6ca9b124dc92b246c7a404e762f45b (commit)
via 7f7a5da483ea4051123b48437b35fdba7c7e46fe (commit)
via a7714243d5a88e455440f4435e26a3ecad33b0d5 (commit)
via f0e3196e095f31e7a2f68fc14e79413215b5ff83 (commit)
via b98a051dc4268f065e07e931fce1ad1863865276 (commit)
via b0ee073d8eef8d2c8bdca16031ca1ca519a74710 (commit)
via 40f9e3d5e75085ffe15274c2d124188cf21e5420 (commit)
via 18e008c206899d2092f5a73b4e0337304f02ffda (commit)
via bc9724006933fbc870dacefa9d37d6fd9a24b4e5 (commit)
via d4bfb7ba7d7bb6598c8b0016331e6144efd2c85e (commit)
via ea17703152a118f0192dab94722196ece72adbef (commit)
via 3993ae988587e8733052944634a648e9bdb1275d (commit)
via c351dfc0cf7f4e0ee7c1129db12a078a7e2857fb (commit)
via e745fad6c4ff139f3e7d407fd054ac9c389d2286 (commit)
from 651f86e0861ca03102d07bf12c7d9604d6ab5d43 (commit)
Summary of changes:
lib/DBIx/SearchBuilder/Handle.pm | 85 ++++++++
lib/DBIx/SearchBuilder/Handle/Oracle.pm | 36 ++++
lib/DBIx/SearchBuilder/Handle/mysql.pm | 80 ++++++++
t/03cud_from_select.t | 331 +++++++++++++++++++++++++++++++
4 files changed, 532 insertions(+), 0 deletions(-)
create mode 100644 t/03cud_from_select.t
- Log -----------------------------------------------------------------
commit cb392b12b389b72ebff8562ccda632ba4e1d5aaf
Merge: 651f86e 8e4478b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Sep 15 18:49:14 2011 +0400
Merge branch 'cud-from-select'
Conflicts:
lib/DBIx/SearchBuilder/Handle/Oracle.pm
diff --cc lib/DBIx/SearchBuilder/Handle/Oracle.pm
index d92f472,2eb7a17..cd7dca9
--- a/lib/DBIx/SearchBuilder/Handle/Oracle.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Oracle.pm
@@@ -162,6 -117,80 +162,42 @@@ sub Insert
return( $self->{'id'}); #Add Succeded. return the id
}
-
+ =head2 InsertFromSelect
+
+ Customization of L<DBIx::SearchBuilder::Handle/InsertFromSelect>.
+
+ Unlike other DBs Oracle needs:
+
+ =over 4
+
+ =item * id generated from sequences for every new record.
+
+ =item * query wrapping in parens.
+
+ =back
+
+ B<NOTE> that on Oracle there is a limitation on the query. Every
+ column in the result should have unique name or alias, for example the
+ following query would generate "ORA-00918: column ambiguously defined"
+ error:
+
+ SELECT g.id, u.id FROM ...
+
+ Solve with aliases:
+
+ SELECT g.id AS group_id, u.id AS user_id FROM ...
+
+ =cut
+
+ sub InsertFromSelect {
+ my ($self, $table, $columns, $query, @binds) = @_;
+ if ( $columns && !grep lc($_) eq 'id', @$columns ) {
+ unshift @$columns, 'id';
+ $query = "SELECT ${table}_seq.nextval, insert_from.* FROM ($query) insert_from";
+ }
+ return $self->SUPER::InsertFromSelect( $table, $columns, "($query)", @binds);
+ }
+
-=head2 BuildDSN PARAMHASH
-
-Takes a bunch of parameters:
-
-Required: Driver, Database or Host/SID,
-Optional: Port and RequireSSL
-
-Builds a DSN suitable for an Oracle DBI connection
-
-=cut
-
-sub BuildDSN {
- my $self = shift;
- my %args = ( Driver => undef,
- Database => undef,
- Host => undef,
- Port => undef,
- SID => undef,
- RequireSSL => undef,
- @_);
-
- my $dsn = "dbi:$args{'Driver'}:";
-
- if (defined $args{'Host'} && $args{'Host'}
- && defined $args{'SID'} && $args{'SID'} ) {
- $dsn .= "host=$args{'Host'};sid=$args{'SID'}";
- } else {
- $dsn .= "$args{'Database'}" if (defined $args{'Database'} && $args{'Database'});
- }
- $dsn .= ";port=$args{'Port'}" if (defined $args{'Port'} && $args{'Port'});
- $dsn .= ";requiressl=1" if (defined $args{'RequireSSL'} && $args{'RequireSSL'});
-
- $self->{'dsn'}= $dsn;
-}
-
-
-
=head2 KnowsBLOBs
Returns 1 if the current database supports inserts of BLOBs automatically.
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list