Revision history for DBIx::Class
-0.08203_01 2012-10-18 13:57 (UTC)
+ * New Features / Changes
+ - SQLMaker now accepts \'literal' with the 'for' rs attribute as an
+ override to the builtin FOR options
* Fixes
- Fix test failure on perl 5.8
=over 4
-=item Value: ( 'update' | 'shared' )
+=item Value: ( 'update' | 'shared' | \$scalar )
=back
Set to 'update' for a SELECT ... FOR UPDATE or 'shared' for a SELECT
-... FOR SHARED.
+... FOR SHARED. If \$scalar is passed, this is taken directly and embedded in the
+query.
=cut
};
sub _lock_select {
my ($self, $type) = @_;
- my $sql = $for_syntax->{$type} || $self->throw_exception( "Unknown SELECT .. FOR type '$type' requested" );
+
+ my $sql;
+ if (ref($type) eq 'SCALAR') {
+ $sql = "FOR $$type";
+ }
+ else {
+ $sql = $for_syntax->{$type} || $self->throw_exception( "Unknown SELECT .. FOR type '$type' requested" );
+ }
+
return " $sql";
}
);
}
+# Tests base class for => \'FOO' actually generates proper query. for =>
+# 'READ'|'SHARE' is tested in db-specific subclasses
+# we have to instantiate base because SQLMaker::SQLite disables _lock_select
+{
+ require DBIx::Class::SQLMaker;
+ my $sa = DBIx::Class::SQLMaker->new;
+ {
+ my ($sql, @bind) = $sa->select('foo', '*', {}, { for => 'update' } );
+ is_same_sql_bind(
+ $sql,
+ \@bind,
+ 'SELECT * FROM foo FOR UPDATE',
+ [],
+ );
+ }
+
+ {
+ my ($sql, @bind) = $sa->select('bar', '*', {}, { for => \'baz' } );
+ is_same_sql_bind(
+ $sql,
+ \@bind,
+ 'SELECT * FROM bar FOR baz',
+ [],
+ );
+ }
+
+}
+
+
+
# Make sure the carp/croak override in SQLA works (via SQLMaker)
my $file = quotemeta (__FILE__);
throws_ok (sub {