Using $1::regtype will raise an error if the type does not exist. An example is if the hstore is not installed in the db.
ref sqlalchemy/sqlalchemy#8631 (comment) and sqlalchemy/sqlalchemy#8631 (comment)
cc @om26er
note: it seems to_regtype was added in 9.4 (at least the documentation of 9.3 does not mention it)