aboutsummaryrefslogtreecommitdiffstats
path: root/test/visitors/test_to_sql.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use a specific exception for unsupported visitsSammy Larbi2015-07-141-3/+3
|
* remove extra space before 'ORDER BY'Nihad Abbasov2014-11-261-1/+8
|
* Use class objects rather than strings for the dispatch cacheSean Griffin2014-11-181-1/+1
| | | | | | | | The only reason we're using strings is to pre-populate the cache, but `Class#name` returns a new string instance on every call. This is a pretty major source of memory usage. We don't technically need to pre-populate the cache, and not doing so allows us to go back to using cache objects
* Add order to BindParams in the ToSql collectorSean Griffin2014-11-171-2/+9
| | | | | | | | | | | | 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.
* Deprecate passing ranges to `#in` and `#not_in`Sean Griffin2014-10-251-12/+12
| | | | | | | The goal of these methods should be to generate in nodes, not handle every possible permutation of more than one value. The `#between` and `#not_between` methods have been extracted, which better represent the semantics of handling ranges in SQL.
* `#not_in` with a range should respect proper precedenceSean Griffin2014-10-241-6/+6
| | | | | | | | | | | | | | | | | | Currently, doing ```ruby relation[:id].not_eq(4).and(relation[:id].not_in(1..3)) ``` will generate ```sql "id" != 4 AND "id" < 1 OR "id" > 3 ``` Which would incorrectly include records with an id of 4, as the OR statement has higher precidence than the AND statement. The `or` method on `Node` properly groups the statement in parenthesis.
* {Matches,DoesNotMatch} support the ESCAPE clauseTamir Duberstein2014-09-251-0/+14
|
* move the dispatch table to be per-instanceAaron Patterson2014-09-221-1/+1
| | | | | | | visitors are not shared among threads, so any mutations to the cache should be OK. The cache is also pre-populated on construction, but we should pull that out so we can share the cache among visitors in the future.
* Fix set visiting specDimko2014-09-171-1/+1
|
* Merge pull request #137 from dimko/visit_setRafael Mendonça França2014-09-171-0/+5
|\ | | | | Added a visitor for Set objects
| * added a visitor for Set objectsDimko2012-09-181-0/+5
| |
* | Merge pull request #277 from sergey-alekseev/wrap-nested-gropings-only-onceRafael Mendonça França2014-09-121-0/+7
|\ \ | | | | | | Wrap nested Nodes::Grouping in brackets only once
| * | Wrap nested Nodes::Grouping in brackets only onceSergey Alekseev2014-05-261-0/+7
| | |
* | | - Fix ambiguous argument warningVipul A M2014-05-311-1/+1
| | | | | | | | | | | | - Fix typo: `test_opertaion_ordering` => `test_operation_ordering`
* | | Asserting on error messageBrock Trappitt2014-05-281-3/+2
| | |
* | | Test which checks the error being raised by #unsupported in ToSql VisitorBrock Trappitt2014-05-271-0/+6
|/ /
* | Test quoting integers when comparing a string column with integers.Dylan Smith2014-04-281-2/+14
| | | | | | | | | | | | | | | | | | | | An equality with a string column and integer like SELECT * FROM `users` WHERE `login_token` = 0 LIMIT 1; will match match any string that doesn't start with a digit in certain databases, like mysql. Make sure we quote the integer to avoid this problem in a database independant way.
* | postgresql visitor is workingAaron Patterson2014-04-081-2/+1
| |
* | push reduction visitors to a reduction base classAaron Patterson2014-04-081-1/+1
| | | | | | | | this lets our old depth first and dot visitors to work normally
* | Merge branch 'master' into collectorAaron Patterson2014-04-081-0/+20
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: remove order_clauses since we do not use it fix whitespace and unsupported method args Add Regexp and NotRegexp nodes for PostgreSQL Revert "Merge pull request #253 from corrupt952/master" flatten object.children in visit_Arel_Node_And Added right and full outer joins Conflicts: lib/arel/visitors/to_sql.rb lib/arel/visitors/visitor.rb
| * | Add Regexp and NotRegexp nodes for PostgreSQLJames Le Cuirot2014-04-081-0/+20
| | |
| * | Revert "Merge pull request #253 from corrupt952/master"Aaron Patterson2014-04-071-2/+2
| | | | | | | | | | | | | | | This reverts commit 6d3ed6d96c4a3ac85b97d81bad95b7254b2aa2d4, reversing changes made to a35fede61ac1a2fcff519ad052f2fcb8808922b9.
| * | flatten object.children in visit_Arel_Node_AndKazuki Hasegawa2014-04-031-2/+2
| | |
* | | to_sql is passingAaron Patterson2014-04-081-63/+63
| | |
* | | fixing some tests in to_sqlAaron Patterson2014-04-081-14/+19
|/ /
* | Removed all the fiels in lib/arel/visitors/ which needs dependency on 'a' ↵Alex Lin2014-03-241-1/+1
| | | | | | | | also fixed the test case for : test/visitors/test_to_sql.rb:22 which pass in the parameter attribute e.g the parameter a.
* | add the casting node to the AST at build timeAaron Patterson2014-03-241-17/+61
| | | | | | | | | | If we add the casting node to the ast at build time, then we can avoid doing the lookup at visit time.
* | Test case for Issue No 242.cmohanprasath2014-02-181-0/+11
| | | | | | | | The evaluates the assignment of two unqualified columns.
* | Add tests for Nodes::Equality and Nodes::NotEqual to the ToSql class.Roel van der Hoorn2014-02-071-10/+25
| |
* | Add tests for PostgreSLQ bugfix regarding invalid SQL in subqueries when ↵Roel van der Hoorn2014-02-051-0/+34
| | | | | | | | using matches() or does_not_match().
* | Make visitors threadsafe by removing @last_columnErnie Miller2013-04-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Support Float::INFINITY in rangesTim Pope2013-02-191-0/+34
| |
* | Merge pull request #140 from sunaku/GH-139Aaron Patterson2012-09-241-0/+39
|\ \ | | | | | | bugfix: some aggregations lacked DISTINCT emission
| * | GH-139: some aggregations lacked DISTINCT emissionSuraj N. Kurapati2012-09-211-0/+39
| |/
* / to_sql: add support for emitting SQL subqueriesSuraj N. Kurapati2012-09-221-0/+5
|/
* Fix in [] to be false, in [] to be trueErnie Miller2012-06-141-8/+4
| | | | This is in response to discussion on 62207fa
* Do not generate NOT IN (NULL) when empty rightSantiago Pastorino2012-06-131-4/+4
|
* bind parameters can be differentiated from sql literalsAaron Patterson2012-02-201-0/+6
|
* calling cache methods against the connectionAaron Patterson2011-11-191-21/+3
|
* Make it the responsibility of the connection to hold on to a visitor for ↵Jon Leighton2011-08-081-3/+3
| | | | generating SQL, rather than the TreeManager. (There is a related commit coming in Active Record.)
* Add nodes for boolean constantsDaniel Cadenas2011-08-031-0/+16
| | | | | | | | | | | | This is useful for dynamically created predicates e.g: expr1 = table.create_false expr2 = table.create_false expr1 = create_a_predicate() if some_condition expr2 = create_another_predicate() if some_other_condition table.where(expr1.and(expr2))
* visitors can define their own cache strategy for dispatch. fixes #57Aaron Patterson2011-06-271-0/+16
|
* make sure thread runsAaron Patterson2011-05-171-0/+1
|
* no longer use this instance variableAaron Patterson2011-05-171-1/+1
|
* Make ToSql more thread safe.Damon McCormick + Cameron Walters2011-05-101-0/+17
| | | | | | | Because the ToSql visitor instance is shared across all threads, there is a race condition around column types for binary nodes. It's possible, for instance, to end up with ActiveRecord converting a string value in the final SQL to an integer during heavy concurrent operations.
* raising not implemented exceptions for distinct on where it is not supportedAaron Patterson2011-04-211-0/+11
|
* Replace MathOperation with InfixOperation to support more operatorsErnie Miller2011-03-091-1/+10
|
* Merge branch 'master' of github.com:rails/arelAaron Patterson2011-03-071-0/+9
|\ | | | | | | | | * 'master' of github.com:rails/arel: Add an #table_name method to Table and TableAlias, which always returns the actual table name, not the alias. Then fix ToSql#column_for to use this table name when checking whether the table exists (rather than before, where it was checking whether a table with the alias name exists, which was incorrect).
| * Add an #table_name method to Table and TableAlias, which always returns the ↵Jon Leighton2011-03-041-0/+9
| | | | | | | | actual table name, not the alias. Then fix ToSql#column_for to use this table name when checking whether the table exists (rather than before, where it was checking whether a table with the alias name exists, which was incorrect).
* | Merge remote branch 'stiff/master' into omgAaron Patterson2011-03-071-0/+22
|\ \ | |/ |/| | | | | * stiff/master: implemented support for math operations in numeric attributes