DownloadTicketService / dl

Download Ticket Service
https://www.thregr.org/~wavexx/software/dl/
GNU General Public License v2.0
84 stars 30 forks source link

DL 18.1: boolean settings for postgres backend broken #71

Open wavexx opened 6 years ago

wavexx commented 6 years ago

Reported by Dima Veselov:

Main problem is that PostgreSQL unlike others do not accept boolean as 1 or 0 - only as true or false.

I managed to make this work changing code to: ticketfunc.php:122 $sql .= ", " . (!isset($params["pass_send"])? 'false': to_boolean($params["pass_send"]));

func.php:

function to_boolean($v)
{
  if($v === 1 || $v === "1" || $v === "true") {error_log("FIRE
$v");return "true";}
  elseif($v === 0 || $v === "0" || $v === "false" || $v === FALSE)
return "false";
  return null;
}

Sorry, can't check if this break other database logic. Also, dbupgrade.php should be remastered, I executed it manually.

wavexx commented 6 years ago

I wonder how this ever worked, honestly. To my dismay, given how (fake) booleans interact with mysql and sqlite, I'll actually change the column type in postgres to a smallint to gain uniform behavior.

jenszahner commented 6 years ago

Could you be so kind to take a look at #73 for type safety during sql statements.