Created
November 13, 2014 14:10
-
-
Save evansd/6127048f9efcf7889b96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def limit_with_cte(queryset, limit=None): | |
| if limit is None: | |
| return queryset | |
| sql, params = queryset.query.sql_with_params() | |
| cte_query = 'WITH cte_table_a4eb61 AS ({}) '\ | |
| 'SELECT * FROM cte_table_a4eb61 LIMIT {:d}'.format( | |
| sql, int(limit)) | |
| return queryset.raw(cte_query, params) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment