Please sign in to comment.
Make visitors threadsafe by removing @last_column
The last_column feature of the ToSql visitor and its descendants is what enabled quoting based on the column last visited -- in other words, if you have a standard condition like an equality with a string attribute on the left side and an integer on the right side, then when ARel visits the node, it'll first visit the left side attribute, setting the column of the string attribute as the last column, and resulting in the right side of the condition getting the appropriate quoting. The downside is that this means that visitors can't be shared between threads, because of the state mutation. It also makes for some really weird behavior in the event that the visitor visits a node that happens to contain an attribute you weren't expecting to be there, since it'll potentially quote something based on that attribute. So, it prevents reversing an equality condition. column = value will work, but not value = column, since the last column wouldn't be the column you're hoping for. This is a first pass at fixing this by changing the signature of the visit methods to accept the currently-relevant attribute, if any.
- Loading branch information...
Showing with 386 additions and 382 deletions.
- +4 −4 lib/arel/visitors/bind_visitor.rb
- +56 −56 lib/arel/visitors/depth_first.rb
- +75 −75 lib/arel/visitors/dot.rb
- +2 −2 lib/arel/visitors/ibm_db.rb
- +17 −17 lib/arel/visitors/informix.rb
- +2 −2 lib/arel/visitors/join_sql.rb
- +12 −12 lib/arel/visitors/mssql.rb
- +15 −15 lib/arel/visitors/mysql.rb
- +17 −17 lib/arel/visitors/oracle.rb
- +2 −2 lib/arel/visitors/order_clauses.rb
- +6 −6 lib/arel/visitors/postgresql.rb
- +2 −2 lib/arel/visitors/sqlite.rb
- +171 −167 lib/arel/visitors/to_sql.rb
- +2 −2 lib/arel/visitors/visitor.rb
- +2 −2 lib/arel/visitors/where_sql.rb
- +1 −1 test/visitors/test_to_sql.rb
Oops, something went wrong.