Please sign in to comment.
Refactor and modularize Dataset#sql_select, and refactor database ada…
…pters that override it This is a long overdue change to Sequel that makes select_sql more modular and makes database adapters to only override the parts they need to override instead of overriding the entire method (which requires a lot of code duplication). Unfortunately, I can't test the changes I made to most of the adapters, as I don't have access to the underlying databases. If you use one of the following adapters, please test this commit and make sure it works: * Informix * MSSQL * Oracle This also makes some changes to existing code. Attempting to do a SELECT DISTINCT ON will now raise an error with the MySQL or Oracle adapters, as they support DISTINCT but not DISTINCT ON. Previously, the MySQL adapter would raise a DatabaseError when you ran the query, and the Oracle adapter would silently change the DISTINCT ON to a plain DISTINCT, which potentially changes the intended meaning. The refactoring is done by splitting the public select_sql method into a bunch of private select_*_sql methods. The select_clause_order private method is the list of methods to call in order. So if it was [:columns, :from], it would call select_columns_sql and then select_from_sql to build the string. All of the private select_*_sql methods take 2 arguments, the current SQL string and the option hash to use. The SQL string passed should be modified in place. Database adapters have been changed to override just the select_*_sql methods they need, as well as select_clause_order if they need the clauses in a different order than the default. Another small change made is that the Dataset#column_list private method now treats a nil argument the same as an  argument. This makes other internal code that uses the method nicer.
- Loading branch information...
Showing with 152 additions and 194 deletions.
Oops, something went wrong. Retry.