Skip to content

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

@matthewmcgarvey

Description

@matthewmcgarvey

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions