Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting CTE #1005

Open
jwoertink opened this issue Feb 18, 2024 · 0 comments
Open

Supporting CTE #1005

jwoertink opened this issue Feb 18, 2024 · 0 comments
Labels
feature request A new requested feature / option

Comments

@jwoertink
Copy link
Member

I use a lot of these thing, and always have to drop to raw SQL because of it. It would be great if Avram had it built right in

Here's my initial proposal

schedule_query = <<-SQL
SELECT ...
SQL
UserQuery.new.with_cte(:schedules, as: schedule_query)

Or maybe go the route of Avram::Join with something like Avram::CTE https://github.com/luckyframework/avram/blob/main/src/avram/join.cr

cte = Avram::CTE.new(:schedules) do |io|
  io << "SELECT ... FROM ...."
end

UserQuery.new.with_cte(cte)

I'll have to research a bit more of how many of my raw queries could be converted through this method. I know not all of them, but this could possibly clear up quite a bit.

@jwoertink jwoertink added the feature request A new requested feature / option label Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A new requested feature / option
Projects
None yet
Development

No branches or pull requests

1 participant