• C
    Allow CTEs in read-only queries. · 9889308b
    chrismo 提交于
    Common Table Expressions in PostgreSQL allow a different way to define
    derived tables. Here's an example from the pg docs:
    
    	WITH regional_sales AS (
    	        SELECT region, SUM(amount) AS total_sales
    	        FROM orders
    	        GROUP BY region
    	     ), top_regions AS (
    	        SELECT region
    	        FROM regional_sales
    	        WHERE total_sales > (SELECT SUM(total_sales)/10 FROM regional_sales)
    	     )
    	SELECT region,
    	       product,
    	       SUM(quantity) AS product_units,
    	       SUM(amount) AS product_sales
    	FROM orders
    	WHERE region IN (SELECT region FROM top_regions)
    	GROUP BY region, product;
    
    https://www.postgresql.org/docs/current/queries-with.html
    
    This commit adds the :with keyword to the set of keywords allowed to
    begin a query against a `prevent_writes` PostgreSQL connection.
    
    Thx to @kamipo, this also adds the same support for sqlite3 and mysql2
    
    https://www.sqlite.org/lang_with.html
    https://dev.mysql.com/doc/refman/8.0/en/with.html
    9889308b
postgresql_adapter_test.rb 18.1 KB