aboutsummaryrefslogtreecommitdiffstats
path: root/test/collectors
Commit message (Collapse)AuthorAgeFilesLines
* Add a collector to grab the bind values off the ASTSean Griffin2017-07-212-0/+87
| | | | | | | | Now that the bind values are being stored on the actual AST, we need a way to pull them off into the array that we were previously maintaining separately. This requires a full walk of the AST. This is an expensive operation, so I've also added a visitor for delegating to more than one visitor in a single pass.
* Ensure `ToSql` collector returns a UTF-8 stringSean Griffin2017-07-211-0/+8
| | | | | | | | Switching from `''.dup` to `String.new` had the side effect of changing the encoding on Ruby 2.4 and later. Oddly, `String.new(encoding: Encoding::UTF_8)` is significantly slower than `''.dup`. This seems like a bug in Ruby, but not something we're going to address right now. A test has been added to ensure this regression doesn't occur again.
* Refactor `substitute_binds` to perform substitution immediatelySean Griffin2017-07-211-45/+21
| | | | | | | | | | | | | | | | | | I'm honestly not sure if replacing bind params with their concrete values is something that belongs in Arel at all, as it's something that will need to be coupled to the quoting mechanism of the caller, and could just be accomplished by using `Quoted` instead. Still, with the new structure we can provide a much simpler API around substitution. The expectation of the quoter responding to `quote` is a reasonably minimal API. I originally used `DelegateClass` here, with the one line override of `add_bind`, but realized that we have some funky code going on where the collector returns the next collector to use (in practice `self` is always returned, and I don't see why we'd ever want to do this). Removing that would likely be worthwhile, but would be a larger refactoring
* Add a value field `Nodes::BindParam`Sean Griffin2017-07-212-6/+6
| | | | | | | | | | | | | | | | | | | | This is part of a greater refactoring to have the `BindParam` nodes hold onto their values. We want to generally keep the AST decoupled from what you're actually doing with those values, but ultimately the usage of `BindParam` is almost identical to how you'd use `Casted` or `Quoted`. Forcing consumers of Arel's API to maintain the bind values separately from the AST makes manipulating the AST essentially impossible, as you would need to perform a full walk of the AST to determine whether a given node contains bind parameters, and which value it maps to. By storing the value on the bind parameter directly, we can collect them in another AST pass (realistically it'll be part of the same pass that performs SQL construction for performance reasons). This will dramatically simplify AST manipulation for Rails or any other consumers that work with bind params. As part of this change I've removed the `BindVisitor`, which appears to be dead code, and had tests break from this change.
* Rename `Collectors::Bind`Sean Griffin2017-07-212-3/+2
| | | | | | The "bind collector" does not actually collect bind params at all, it substitutes them out of the final AST, replacing them with a quoted value.
* Enable frozen_string_literal in all files in arelRafael Mendonça França2017-02-132-0/+2
|
* Remove `engine` from `TreeManager` and subclassesSean Griffin2014-11-292-2/+2
| | | | | | This constructor parameter was unused for everything except the convenience methods `to_sql` and `where_sql`. We can pass the engine into those methods directly.
* Add order to BindParams in the ToSql collectorSean Griffin2014-11-172-5/+5
| | | | | | | | | | | | This removes the need for us to do the re-ordering by walking the AST in ActiveRecord. We're using a block to communicate with the collector, since the collector needs to be the thing which knows about the index, while the visitor is the thing that needs to know the syntax. The BindParam needs to know about neither of these things, so it's been changed to stop being a subclass of SqlLiteral I could also see an alternative implementation using format strings if for some reason blocks cause a problem.
* Fix warning form bind collector testVipul A M2014-05-251-1/+1
|
* add test for sql string collectorAaron Patterson2014-04-091-0/+38
|
* add a compile method to the collectorsAaron Patterson2014-04-091-0/+8
|
* adding a bind value collectorAaron Patterson2014-04-091-0/+62