X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FAbstract.pm;h=6a03d6f8a4015881c0b4eb3549cb3cff86ec45e7;hb=f2ab166a82ed8b2e1c75b960e7d0fb8209cb6f50;hp=cae7e93a6f188c02e60a2326d3071927181081e2;hpb=20998a570cdbb06e6e8a04ffdb6db1eaf19378f4;p=dbsrgits%2FSQL-Abstract.git diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm index cae7e93..6a03d6f 100644 --- a/lib/SQL/Abstract.pm +++ b/lib/SQL/Abstract.pm @@ -15,7 +15,7 @@ use Scalar::Util (); # GLOBALS #====================================================================== -our $VERSION = '1.66_01'; +our $VERSION = '1.67_03'; # This would confuse some packagers $VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases @@ -1900,6 +1900,20 @@ This simple code will create the following: A field associated to an empty arrayref will be considered a logical false and will generate 0=1. +=head2 Tests for NULL values + +If the value part is C then this is converted to SQL + + my %where = ( + user => 'nwiger', + status => undef, + ); + +becomes: + + $stmt = "WHERE user = ? AND status IS NULL"; + @bind = ('nwiger'); + =head2 Specific comparison operators If you want to specify a different type of operator for your comparison, @@ -2098,7 +2112,7 @@ list can be expanded : see section L below. If you wish to test against boolean columns or functions within your database you can use the C<-bool> and C<-not_bool> operators. For example to test the column C being true and the column - being false you would use:- +C being false you would use:- my %where = ( -bool => 'is_user', @@ -2261,6 +2275,17 @@ which yields $stmt = "WHERE priority < ? AND is_ready"; @bind = ('2'); +Literal SQL is also the only way to compare 2 columns to one another: + + my %where = ( + priority => { '<', 2 }, + requestor => \'= submittor' + ); + +which creates: + + $stmt = "WHERE priority < ? AND requestor = submitter"; + @bind = ('2'); =head2 Literal SQL with placeholders and bind values (subqueries) @@ -2584,6 +2609,12 @@ the same structure, you only have to generate the SQL the first time around. On subsequent queries, simply use the C function provided by this module to return your values in the correct order. +However this depends on the values having the same type - if, for +example, the values of a where clause may either have values +(resulting in sql of the form C with a single bind +value), or alternatively the values might be C (resulting in +sql of the form C with no bind value) then the +caching technique suggested will not work. =head1 FORMBUILDER