From 10cc4ce2b9e1d745f3be91373f48ef6ea9ca7f88 Mon Sep 17 00:00:00 2001
From: Irina Truong <i.chernyavska@gmail.com>
Date: Sun, 9 Jun 2019 08:05:28 -0700
Subject: [PATCH] Partial fix for #1058. (#1068)

---
 changelog.rst      | 5 +++++
 pgcli/pgexecute.py | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/changelog.rst b/changelog.rst
index 323627a2..467afe73 100644
--- changelog.rst
+++ changelog.rst
@@ -6,6 +6,11 @@ Features:
 
 * Add `\\G` as a terminator to sql statements that will show the results in expanded mode. This feature is copied from mycli. (Thanks: `Amjith Ramanujam`_)
 
+Bug fixes:
+----------
+
+* Error connecting to PostgreSQL 12beta1 (#1058). (Thanks: `Irina Truong`_)
+
 2.1.1
 =====
 
diff --git a/pgcli/pgexecute.py b/pgcli/pgexecute.py
index e3c16ffb..b3ebb5c0 100644
--- pgcli/pgexecute.py
+++ pgcli/pgexecute.py
@@ -559,7 +559,7 @@ def _columns(self, kinds=("r", "v", "m")):
                         att.attname column_name,
                         att.atttypid::regtype::text type_name,
                         att.atthasdef AS has_default,
-                        def.adsrc as default
+                        pg_catalog.pg_get_expr(def.adbin, def.adrelid, true) as default
                 FROM    pg_catalog.pg_attribute att
                         INNER JOIN pg_catalog.pg_class cls
                             ON att.attrelid = cls.oid
