diff options
author | Nathan Gass | 2021-01-27 12:23:52 +0100 |
---|---|---|
committer | Nathan Gass | 2021-01-27 12:23:52 +0100 |
commit | 28ac1153604f962093594bcd9b44998636fadb9a (patch) | |
tree | 18eb11e572fa912af00aa9f39191ec2d4f3817d8 /it_dbi_postgres.class | |
parent | 904d3827bdc4b1647b3f7f90cfa93c41ad916c42 (diff) | |
download | itools-28ac1153604f962093594bcd9b44998636fadb9a.tar.gz itools-28ac1153604f962093594bcd9b44998636fadb9a.tar.bz2 itools-28ac1153604f962093594bcd9b44998636fadb9a.zip |
fix boolean handling for postgresql
Diffstat (limited to 'it_dbi_postgres.class')
-rw-r--r-- | it_dbi_postgres.class | 9 |
1 files changed, 9 insertions, 0 deletions
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; } |