lib/pg/doc/engine.rb in pg-doc-0.0.1 vs lib/pg/doc/engine.rb in pg-doc-0.0.2
- old
+ new
@@ -65,11 +65,12 @@
SQL
_recordset.each_with_object(@cache){ |row, h|
h[:schemas][row["schema_name"]] = {
tables: {},
views: {},
- functions: {}
+ functions: {},
+ triggers: {}
}
}
# Load tables
_recordset = @conn.exec <<~SQL
@@ -79,10 +80,11 @@
obj_description((table_schema || '.' || table_name)::regclass::oid, 'pg_class') as comment
FROM
information_schema.tables
WHERE
#{@schema_filter.call :table_schema}
+ AND table_type != 'VIEW'
ORDER BY
1, 2
SQL
_recordset.each_with_object(@cache){ |row, h|
h[:schemas][row["table_schema"]][:tables][row["table_name"]] = {
@@ -148,24 +150,29 @@
routine_schema,
routine_name,
routine_definition,
external_language,
pg_get_function_identity_arguments((routine_schema || '.' || routine_name)::regproc) as arguments,
+ pg_get_functiondef((routine_schema || '.' || routine_name)::regproc) as function_definition,
+ pg_get_function_result((routine_schema || '.' || routine_name)::regproc) as function_result,
obj_description((routine_schema || '.' || routine_name)::regproc::oid, 'pg_proc') as comment
FROM
information_schema.routines
WHERE
#{@schema_filter.call :routine_schema}
AND external_name IS NULL
ORDER BY
1, 2
SQL
_recordset.each_with_object(@cache){ |row, h|
- h[:schemas][row["routine_schema"]][:functions][row["routine_name"]] = {
+ dest = row["function_result"] == "trigger" ? :triggers : :functions
+ h[:schemas][row["routine_schema"]][dest][row["routine_name"]] = {
external_language: row["external_language"],
comment: row["comment"],
- arguments: row["arguments"].split(",").map{ |arg| parse_function_argument arg }
+ arguments: row["arguments"].split(",").map{ |arg| parse_function_argument arg },
+ function_definition: row["function_definition"],
+ function_result: row["function_result"]
}
}
# Load foreign keys
_recordset = @conn.exec <<~SQL
@@ -269,10 +276,10 @@
else
name = nil
type = arg
end
- {name: name, type: type, mode: argmode}
+ {"name" => name, "type" => type, "mode" => argmode}
end
end