Make the Include SQL (in the download) checkbox work
authorKarl O. Pinc <kop@karlpinc.com>
Sun, 29 Sep 2024 22:03:04 +0000 (17:03 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Sun, 29 Sep 2024 22:03:04 +0000 (17:03 -0500)
src/pgwui_sql/views/sql.py

index b3acd11138efbf829a3b94ca65e94c71fc227f92..cdc2fe22c5e7e598431cf037445898a5fa047799 100644 (file)
@@ -282,6 +282,8 @@ class SQLResultsHandler(pgwui_core.core.SessionDBHandler):
         if downloading:
             self.tfile = tempfile.TemporaryFile(mode='w+t', newline='')
             writer = self.make_csv_writer()
+            if self.uf['include_sql']:
+                writer.writerow((self.uf['sql'].rstrip(),))
             for sql_result in sql_results:
                 writer.writerow((sql_result.statusmessage.data,))
                 writer.writerow(sql_result.heading.data)