Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Cvs P5ee > [svn:p5ee] r108...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 665 of 694
Post > Topic >>

[svn:p5ee] r10825 - in p5ee/trunk/App-Repository: . lib/App/Repository t

by spadkins@[EMAIL PROTECTED] Feb 25, 2008 at 12:54 PM

Author: spadkins
Date: Mon Feb 25 12:54:42 2008
New Revision: 10825

Modified:
   p5ee/trunk/App-Repository/CHANGES
   p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm
   p5ee/trunk/App-Repository/t/DBI-getset.t

Log:
enable param substitutions in dbexpr's

Modified: p5ee/trunk/App-Repository/CHANGES
==============================================================================
--- p5ee/trunk/App-Repository/CHANGES	(original)
+++ p5ee/trunk/App-Repository/CHANGES	Mon Feb 25 12:54:42 2008
@[EMAIL PROTECTED]
 -3,6 +3,7 @[EMAIL PROTECTED]
 #########################################
 
 0.966 (not yet released)
+ x App::Repository::mk_select_joined_sql(): enable param substitutions in
dbexpr's
  x App::Repository::get_rows()/get_row(): use query caching if turned on
for the table ({cache_name} => "name_of_shared_datastore")
  x App::Repository::create_temporary_object_set(): can create a temporary
object set with data, not bound to the database
  x App::Repository::create_temporary_object_domain(): can create a
temporary object domain with data, not bound to the database

Modified: p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm	(original)
+++ p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm	Mon Feb 25
12:54:42 2008
@[EMAIL PROTECTED]
 -1116,6 +1116,13 @[EMAIL PROTECTED]
         }
 
         ############################################################
+        # allow param substitutions in dbexpr
+        ############################################################
+        if ($dbexpr =~ /{/) {
+            $dbexpr = $self->substitute($dbexpr, $params);
+        }
+
+        ############################################################
         # accumulate select expressions and their aliases
         ############################################################
         if ($is_summary) {

Modified: p5ee/trunk/App-Repository/t/DBI-getset.t
==============================================================================
--- p5ee/trunk/App-Repository/t/DBI-getset.t	(original)
+++ p5ee/trunk/App-Repository/t/DBI-getset.t	Mon Feb 25 12:54:42 2008
@[EMAIL PROTECTED]
 -41,6 +41,11 @[EMAIL PROTECTED]
                 table => {
                     test_person => {
                         primary_key => ["person_id"],
+                        column => {
+                            years_older => {
+                                dbexpr => "age-{base_age:0}",
+                            },
+                        },
                     },
                 },
             },
@[EMAIL PROTECTED]
 -229,6 +234,16 @[EMAIL PROTECTED]
 is($#$hashes+1, 1, "get_hashes not_matches (?A)");
 
 #print $rep->{sql};
+
+#####################################################################
+# dbexpr with substitutions
+#####################################################################
+my ($years_older);
+$years_older = $rep->get("test_person", {person_id => 1}, "years_older");
+is($years_older, 41, "get() years_older [$years_older] base_age is
undef");
+$years_older = $rep->get("test_person", {person_id => 1, base_age => 20},
"years_older");
+is($years_older, 21, "get() years_older [$years_older] base_age = 20");
+
 exit(0);
 #####################################################################
 #  $rep->set_rows($table, undef,    \@[EMAIL PROTECTED]
 $rows, \%options);




 1 Posts in Topic:
[svn:p5ee] r10825 - in p5ee/trunk/App-Repository: . lib/App/Repo
spadkins@[EMAIL PROTECTED  2008-02-25 12:54:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue May 13 21:42:44 CDT 2008.