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

Allow creating QueryBuilder with "from" as result of subselect #682

Open
matthewmcgarvey opened this issue Jun 7, 2021 · 1 comment
Open

Comments

@matthewmcgarvey
Copy link
Member

Overview

Right now the "from" is set by the passed in table name in the initializer

def initialize(@table)
end

That's not the only way to specify a from in sql, though.

I would like to update the QueryBuilder to keep track of a from instead of table and remove the setting of table in the initialize.

I believe all that would need to change for existing usage to work is to call .from instead of passing the table name into the initialize in the Queryable here

.new(table: table_name)

I would like to add an overloaded from that takes in a QueryBuilder and an alias which would translate to the SQL from (query_builder statement) as ALIAS

Why?

I would like to see Avram have robust layers. You don't need a full model and queryable for this particular sql query? Fine, just use the QueryBuilder for a bit of a nicer experience. And that would be without sacrificing any usability of the higher level constructs.

Ultimately, I would like to be able to experiment with different higher level patterns and need this lower layer to be more flexible.

@matthewmcgarvey
Copy link
Member Author

A blocker for this change is that update and insert don't use "from" so a table_name makes sense. For my goals, I think there would have to be a way to break up the different types of sql statements. I'll keep looking into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant