Recreate this error with this template:
---8<----
{recordsource sql="select if(1,'x ','') as col1, if (1
and 2, 'x ','') as col2"}
col1:{$col1}|<br>
col2:{$col2}
---8<----
This template will output this:
---8<----
col1:x|
col2:x |
---8<----
Notice the trailing space is stripped in col1 but not col2.
================
Report so far:
================
I used db_mysql.inc to create a DB_Sql object in an
external script, and the trailing space is not clipped.
---8<----
<?php
include '/var/www/polymer/db_mysql.inc';
$db = new DB_Sql;
$db->connect("db", "host", 'user', 'password');
$query = "select if(1,'x ','') as col1, if (1 and 2, 'x
','') as col2";
$db->query($query);
$db->next_record();
echo "col1:". $db->f('col1') ."|\n";
echo "col2:". $db->f('col2') ."|\n";
exit;
---8<----
As it should, this give proper results:
---8<----
col1:x |
col2:x |
---8<----
So it seems the problem is somewhere besides
db_mysql.inc; this makes no sense to me so far, as *all
DB access* in Polymer is through db_mysql.inc.
Also tried sticking this code in
function.recordsource.php, one line ahead of where that
file calls $smarty->db->query($sql):
---8<----
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
echo "col1:". $row['col1'] ."|<br>";
echo "col2:". $row['col2'] ."|<br>";
---8<----
This produces the same erroneous output as above. It's
not db_mysql.inc. It seems to be something in the db
connection that Polymer's established.
Moving on to other things for now, as there are ways to
work around this. But this should be resolved eventually.
Ideas to try:
* run the same sql through sqltext and see the results.
* embed php in the template and check results
* create a separate script using prepend.php and check
results.