File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 11# Change log
22
3+ ## Unreleased
4+
5+ ### Fixed
6+
7+ * Strip comments from SQL queries emitted by pg\_ activity (#442 ).
8+
39## pg\_ activity 3.6.1 - 2025-06-03
410
511### Fixed
Original file line number Diff line number Diff line change 66
77@functools .cache
88def get (name : str ) -> str :
9+ r"""Return the SQL query contained in named file, ignoring commented lines.
10+
11+ >>> get('get_version')
12+ 'SELECT version() AS pg_version;'
13+ >>> print(get('get_pg_activity_post_130000')[:101])
14+ SELECT
15+ a.pid AS pid,
16+ a.backend_xmin AS xmin,
17+ a.application_name AS application_name
18+ """
919 path = here / f"{ name } .sql"
20+ s = "-- "
1021 with path .open () as f :
11- return f .read ()
22+ return "\n " .join (
23+ line .rstrip ().split (s , 1 )[0 ]
24+ for line in f
25+ if line .strip () and not line .startswith (s )
26+ )
You can’t perform that action at this time.
0 commit comments