diff --git a/src/parser_function.go b/src/parser_function.go index 595408a..ac63a2c 100644 --- a/src/parser_function.go +++ b/src/parser_function.go @@ -129,6 +129,12 @@ func (parser *ParserFunction) RemapArrayToString(functionCall *pgQuery.FuncCall) return functionCall } +// aclexplode() -> json() +func (parser *ParserFunction) RemapAclExplode(functionCall *pgQuery.FuncCall) *pgQuery.FuncCall { + functionCall.Funcname = []*pgQuery.Node{pgQuery.MakeStrNode("json")} + return functionCall +} + func (parser *ParserFunction) OverrideFunctionCallArg(functionCall *pgQuery.FuncCall, index int, node *pgQuery.Node) { functionCall.Args[index] = node } diff --git a/src/pg_constants.go b/src/pg_constants.go index 3576bca..0749721 100644 --- a/src/pg_constants.go +++ b/src/pg_constants.go @@ -15,6 +15,7 @@ const ( PG_FUNCTION_QUOTE_INDENT = "quote_ident" PG_FUNCTION_ROW_TO_JSON = "row_to_json" PG_FUNCTION_SET_CONFIG = "set_config" + PG_FUNCTION_ACLEXPLODE = "aclexplode" PG_TABLE_PG_AUTH_MEMBERS = "pg_auth_members" PG_TABLE_PG_CLASS = "pg_class" diff --git a/src/query_handler_test.go b/src/query_handler_test.go index 8e3c6eb..f2ee103 100644 --- a/src/query_handler_test.go +++ b/src/query_handler_test.go @@ -107,6 +107,11 @@ func TestHandleQuery(t *testing.T) { "types": {Uint32ToString(pgtype.TextOID)}, "values": {""}, }, + "SELECT (d).grantee AS grantee, (d).grantor AS grantor, (d).is_grantable AS is_grantable, (d).privilege_type AS privilege_type FROM (SELECT pg_catalog.aclexplode(db.datacl) AS d FROM pg_catalog.pg_database db WHERE db.oid = 16388::OID) a": { + "description": {"grantee", "grantor", "is_grantable", "privilege_type"}, + "types": {Uint32ToString(pgtype.TextOID), Uint32ToString(pgtype.TextOID), Uint32ToString(pgtype.TextOID), Uint32ToString(pgtype.TextOID)}, + "values": {"", "", "", ""}, + }, // PG system tables "SELECT oid, typname AS typename FROM pg_type WHERE typname='geometry' OR typname='geography'": { diff --git a/src/query_remapper_select.go b/src/query_remapper_select.go index 1da505c..5be3649 100644 --- a/src/query_remapper_select.go +++ b/src/query_remapper_select.go @@ -107,6 +107,10 @@ func (remapper *QueryRemapperSelect) remappedFunctionName(functionCall *pgQuery. case schemaFunction.Function == PG_FUNCTION_ROW_TO_JSON: return remapper.parserFunction.RemapRowToJson(functionCall) + // aclexplode(acl) -> json + case schemaFunction.Function == PG_FUNCTION_ACLEXPLODE: + return remapper.parserFunction.RemapAclExplode(functionCall) + default: return nil }