Author: spadkins
Date: Fri Dec 18 15:10:43 2009
New Revision: 13689
Modified:
p5ee/trunk/App-Repository/t/DBI-select-join.t
p5ee/trunk/App-Repository/t/DBI-select.t
Log:
added a test for where columns which are strings but the values look like
numbers
Modified: p5ee/trunk/App-Repository/t/DBI-select-join.t
==============================================================================
--- p5ee/trunk/App-Repository/t/DBI-select-join.t (original)
+++ p5ee/trunk/App-Repository/t/DBI-select-join.t Fri Dec 18 15:10:43 2009
@@ -162,7 +162,7 @@
},
},
column => {
- country_nm => { dbexpr => "ctry.country_nm", },
+ country_nm => { dbexpr => "ctry.country_nm", quoted =>
1, },
city_country_nm => { dbexpr => "ctyctry.country_nm", },
gender => { alias => "gnd", },
},
@@ -344,6 +344,27 @@
is($sql, $expect_sql, "_mk_select_joined_sql(): non-selected param");
&check_select($sql,4);
+$expect_sql = <<EOF;
+select
+ p.first_name
+from test_person p
+where p.last_name = '9999'
+EOF
+$sql = $rep->_mk_select_joined_sql("test_person",{last_name =>
"9999"},"first_name");
+is($sql, $expect_sql, "_mk_select_joined_sql(): where column on native table
looks like a number but is a string");
+&check_select($sql,0);
+
+$expect_sql = <<EOF;
+select
+ p.first_name
+from test_person p
+ inner join test_country ctry on ctry.country = p.country
+where ctry.country_nm = '9999'
+EOF
+$sql = $rep->_mk_select_joined_sql("test_person",{country_nm =>
"9999"},"first_name");
+is($sql, $expect_sql, "_mk_select_joined_sql(): where column on joined table
looks like a number but is a string");
+&check_select($sql,0);
+
$birth_dt = ($dbtype eq "mysql") ? "'1962-01-01'" :
"to_date('1962-01-01','YYYY-MM-DD')";
$expect_sql = <<EOF;
select
Modified: p5ee/trunk/App-Repository/t/DBI-select.t
==============================================================================
--- p5ee/trunk/App-Repository/t/DBI-select.t (original)
+++ p5ee/trunk/App-Repository/t/DBI-select.t Fri Dec 18 15:10:43 2009
@@ -191,6 +191,16 @@
is($sql, $expect_sql, "_mk_select_sql(): non-selected param");
&check_select($sql,0);
+$expect_sql = <<EOF;
+select
+ first_name
+from test_person
+where zip = '30062'
+EOF
+$sql = $rep->_mk_select_sql("test_person",{zip => "30062"},"first_name");
+is($sql, $expect_sql, "_mk_select_sql(): zip looks like number but is a
string");
+&check_select($sql,0);
+
$birth_dt = ($dbtype eq "mysql") ? "'1962-01-01'" :
"to_date('1962-01-01','YYYY-MM-DD')";
$expect_sql = <<EOF;
select
@@ -1034,6 +1044,15 @@
EOF
&test_get_rows($expect_sql,0,"_mk_select_joined_sql():
key","test_person",1,"age");
+$expect_sql = <<EOF;
+select
+ t1.first_name cn13
+from
+ test_person t1
+where t1.zip = '30062'
+EOF
+&test_get_rows($expect_sql,0,"_mk_select_joined_sql(): key","test_person",{
zip => "30062" },"first_name");
+
#$expect_sql = <<EOF;
#select
# t1.age cn13