diff --git a/database/drivers/postgres/parse.go b/database/drivers/postgres/parse.go index fae81eb..f3da1ce 100644 --- a/database/drivers/postgres/parse.go +++ b/database/drivers/postgres/parse.go @@ -597,14 +597,12 @@ func queryTableComments(log *log.Logger, db *sql.DB, schemaNames []string) ([]ta func queryEnums(log *log.Logger, db *sql.DB, schemas []string) (map[string][]*database.Enum, error) { // TODO: make this work with Gnorm generated types - const q = ` - SELECT n.nspname, t.typname as type - FROM pg_type t - LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace - JOIN pg_enum e ON t.oid = e.enumtypid - WHERE (t.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) - AND NOT EXISTS(SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem AND el.typarray = t.oid) - AND n.nspname IN (%s)` + const q = `SELECT n.nspname, t.typname AS type + FROM pg_type t + JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace + WHERE typtype='e' + AND n.nspname IN (%s)` + spots := make([]string, len(schemas)) vals := make([]interface{}, len(schemas)) for x := range schemas { diff --git a/go.mod b/go.mod index d477a8c..d944800 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/jessevdk/go-flags v1.4.0 // indirect github.com/jinzhu/inflection v1.0.0 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/lib/pq v0.0.0-20170810061220-e42267488fe3 + github.com/lib/pq v1.10.4 github.com/magefile/mage v1.10.0 github.com/mattn/go-runewidth v0.0.2 // indirect github.com/natefinch/gocog v0.0.0-20170818170132-3af1fb832aae // indirect diff --git a/go.sum b/go.sum index 47e9e61..bf8b0ec 100644 --- a/go.sum +++ b/go.sum @@ -26,6 +26,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lib/pq v0.0.0-20170810061220-e42267488fe3 h1:2Fs7SMFLrtkGta5HodD3MRV3nIzv+6I90eSfqwPklbo= github.com/lib/pq v0.0.0-20170810061220-e42267488fe3/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= +github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/magefile/mage v1.10.0 h1:3HiXzCUY12kh9bIuyXShaVe529fJfyqoVM42o/uom2g= github.com/magefile/mage v1.10.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC63o=