-
Notifications
You must be signed in to change notification settings - Fork 67
Description
Overview
Right now the "from" is set by the passed in table name in the initializer
avram/src/avram/query_builder.cr
Lines 18 to 19 in 72ac1d6
| 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
Line 48 in 72ac1d6
| .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.