In trying to figure out some NULL sorting handling issues, I ran into #10, and in particular the suggestion to use COALESCE to turn a null value to a non-value.
In order to allow this kind of functionality for dynamic queries, I am suggesting that the table and column name obtained from the connection be passed to the sql function. In other words, in here, a change along the lines of:
table = connection.quote_table_name(scope.table_name)
column = connection.quote_column_name(column.name)
if sql
sql.respond_to?(:call) ? sql.call(table, column) : sql
else
"#{table}."\
"#{column}"
This allows me to call COALESCE using the resolved table name, as I don't have access to the connection in the custom sql proc.
If you're open to this, I can submit a PR.
Thank you!
In trying to figure out some
NULLsorting handling issues, I ran into #10, and in particular the suggestion to useCOALESCEto turn a null value to a non-value.In order to allow this kind of functionality for dynamic queries, I am suggesting that the table and column name obtained from the connection be passed to the sql function. In other words, in here, a change along the lines of:
This allows me to call
COALESCEusing the resolved table name, as I don't have access to the connection in the custom sql proc.If you're open to this, I can submit a PR.
Thank you!