forked from jeremyevans/sequel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split ComplexExpression functionality into three subclasses: BooleanExpression, NumericExpression, and StringExpression. Each subclass implements certain methods that the other subclasses do not. BooleanExpression: &, |, ~ NumericExpression: +, -, *, /, <, >, <=, >= StringExpression: like, <, >, <=, >= The methods are defined in the BooleanMethods, NumericMethods, StringMethods, and InequalityMethods modules, which are included in the above classes as necessary. All modules are included in the ComplexExpressionMethods module which is included in LiteralString, Symbol, and SQL::Function. ComplexExpressionMethods used to be included in SQL::Expression, but it only really makes sense for SQL::Function, and would have caused problems if it were included in SQL::Expression, since ComplexExpression is a subclass of that. ComplexExpressionMethods also has three new methods: sql_boolean, sql_number, and sql_string, which return the receiver wrapped in the appropriate type of expression. This can be useful if other libraries overwrite the operators for classes that Sequel defines the SQL for. For example, I ran into a situation where Symbol#/ was defined to make file system path creation easier, but it returned the result as a string, which Sequel produced the wrong SQL with (quoting it as a string). The fix was to use :symbol.sql_number/10.
- Loading branch information
1 parent
b582d6a
commit e7b2375
Showing
6 changed files
with
295 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.