Project

General

Profile

« Previous | Next » 

Revision 3206

sql.py: DbConn.run_query(): Separate the data source comment from the query with a tab in the executed query but a \r in the logged query, so that the query will be shown on the same line as the data source comment in pg_stat_activity, but be hidden by the following line when cating the file and be put on a separate line when viewed in a text editor. This causes the first line of the query to be at the left edge when the log file is viewed, so that it looks more natural.

View differences:

lib/sql.py
348 348
        assert query != None
349 349
        
350 350
        if self.autocommit and self.src != None:
351
            query = sql_gen.esc_comment(self.src)+' '+query
351
            query = sql_gen.esc_comment(self.src)+'\t'+query
352 352
        
353 353
        if not self.caching: cacheable = False
354 354
        used_cache = False
......
357 357
            if used_cache: cache_status = 'cache hit'
358 358
            elif cacheable: cache_status = 'cache miss'
359 359
            else: cache_status = 'non-cacheable'
360
            
361
            # So that the src comment is hidden when cating the file, and put
362
            # on a separate line when viewed in a text editor.
363
            query = query.replace('\t', '\r', 1)
364
            
360 365
            return 'DB query: '+cache_status+':\n'+strings.as_code(query, 'SQL')
361 366
        
362 367
        try:

Also available in: Unified diff