From 28ac1153604f962093594bcd9b44998636fadb9a Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Wed, 27 Jan 2021 12:23:52 +0100 Subject: fix boolean handling for postgresql --- it_dbi_postgres.class | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'it_dbi_postgres.class') diff --git a/it_dbi_postgres.class b/it_dbi_postgres.class index c26f5fc..2483ab9 100644 --- a/it_dbi_postgres.class +++ b/it_dbi_postgres.class @@ -54,6 +54,11 @@ function _tables($p = array()) return (array)$result; } +static function _convertbool($v) +{ + return $v == 't' ? true : false; +} + function _get_field_defs() { list($table_name, $table_schema) = array_reverse(explode('.', $this->_p['table'], 2)); @@ -71,7 +76,11 @@ function _get_field_defs() $res = $this->query('SELECT * FROM information_schema.columns AS t ' . $where); while ($res && ($field = $this->_fetch_assoc($res))) + { $result[$field['column_name']] = ['Field' => $field['column_name'], 'Type' => $field['data_type'], 'Extra' => it::match('^nextval\(', $field['column_default']) ? 'auto_increment' : '', 'Key' => $keys[$field['column_name']]]; + if ($field['data_type'] == 'boolean') + $result[$field['column_name']] += ['_convertfunc' => 'it_dbi_postgres::_convertbool', '_escapefunc' => 'it_dbi::escape_bool']; + } return $result; } -- cgit v1.2.3