Skip to content

CTE Depercation#122

Draft
GeorgeKaraszi wants to merge 12 commits intomainfrom
cte_deprecation
Draft

CTE Depercation#122
GeorgeKaraszi wants to merge 12 commits intomainfrom
cte_deprecation

Conversation

@GeorgeKaraszi
Copy link
Copy Markdown
Owner

No description provided.

ltrainpr and others added 5 commits October 7, 2025 12:23
* [LC-2396]: Deprecate and Feature-Flag WithCTE for Rails 7.2+

**Summary:**
- Adds a config-driven feature flag (`ActiveRecordExtended.config.with_cte_enabled`) to enable/disable `WithCTE` support at runtime.
- Emits deprecation warnings for `WithCTE` on Rails 7.2+ (native CTE support), with an option to silence warnings (`with_cte_deprecation_warnings_enabled`).
- Disabling the feature raises clear errors if `WithCTE` is used.
- Backward compatible: Rails < 7.2 is unaffected by default.
- Updated README and robust tests for all scenarios.
- Deprecator now uses the actual gem version.

**Migration:**
- For Rails 7.2+, add to an initializer to disable:
  ```ruby
  ActiveRecordExtended.config.with_cte_enabled = false
  ```
- To silence warnings:
  ```ruby
  ActiveRecordExtended.config.with_cte_deprecation_warnings_enabled = false
  ```

**Why:**
- Rails 7.2+ has native CTE support. This change allows safe, configurable migration for all users.

* Update to not raise on rails native supported methods

* Temp: Adds debugging logging

* WIP: Passing most basic with request delegation

* WIP: recursive with

* Get rid of debug logging

* Update tests, README, and Changelog
@douglasshuang
Copy link
Copy Markdown

@GeorgeKaraszi Hi, our project is on Rails 8.0, and we are upgrading soon to 8.1. We are relying on ARE to specify NOT MATERIALIZED for a CTE. We need the CTE encapsulated within a relation (and not coded in raw SQL) so that we can merge it with other relations. I've been unable to find a way to do this natively with Active Record. Do you know how?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants