aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/arel/nodes
Commit message (Collapse)AuthorAgeFilesLines
* Use match? where we don't need MatchDataAkira Matsuda2019-07-291-1/+1
|
* Remove unused `DepthFirst` visitorRyuta Kamizono2019-06-151-19/+0
| | | | | | | | | | | | | We only use `ToSQL` visitors in the our codebase, do not use `DepthFirst` and `Dot` visitors. The `DepthFirst` visitor (which was introduced at c86c37e5f) is used to traverse an Arel (partial) ast with depth first. Is there any worth to keep that undocumented feature with much code and test cases. This removes that unused `DepthFirst` code and test cases.
* Revert unused code and re-using query annotation for `update_all` and ↵Ryuta Kamizono2019-04-013-24/+0
| | | | | | | | | | | | | | | | `delete_all` This partly reverts #35617. #35617 includes unused code (for `InsertStatement`) and re-using query annotation for `update_all` and `delete_all`, which has not been discussed yet. If a relation has any annotation, I think it is mostly for SELECT query, so re-using annotation by default is not always desired behavior for me. We should discuss about desired behavior before publishing the implementation.
* Add Relation#annotate for SQL commentingMatt Yoho2019-03-215-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch has two main portions: 1. Add SQL comment support to Arel via Arel::Nodes::Comment. 2. Implement a Relation#annotate method on top of that. == Adding SQL comment support Adds a new Arel::Nodes::Comment node that represents an optional SQL comment and teachers the relevant visitors how to handle it. Comment nodes may be added to the basic CRUD statement nodes and set through any of the four (Select|Insert|Update|Delete)Manager objects. For example: manager = Arel::UpdateManager.new manager.table table manager.comment("annotation") manager.to_sql # UPDATE "users" /* annotation */ This new node type will be used by ActiveRecord::Relation to enable query annotation via SQL comments. == Implementing the Relation#annotate method Implements `ActiveRecord::Relation#annotate`, which accepts a comment string that will be appeneded to any queries generated by the relation. Some examples: relation = Post.where(id: 123).annotate("metadata string") relation.first # SELECT "posts".* FROM "posts" WHERE "posts"."id" = 123 # LIMIT 1 /* metadata string */ class Tag < ActiveRecord::Base scope :foo_annotated, -> { annotate("foo") } end Tag.foo_annotated.annotate("bar").first # SELECT "tags".* FROM "tags" LIMIT 1 /* foo */ /* bar */ Also wires up the plumbing so this works with `#update_all` and `#delete_all` as well. This feature is useful for instrumentation and general analysis of queries generated at runtime.
* Make `And` and `Case` into expression nodesKevin Deisz2019-01-241-0/+9
| | | | Allows aliasing, predications, ordering, and various other functions on `And` and `Case` nodes. This brings them in line with other nodes like `Binary` and `Unary`.
* Alias case nodesKevin Deisz2019-01-211-0/+10
| | | | When `Arel` was merged into `ActiveRecord` we lost the ability to alias case nodes. This adds it back.
* Add math testsNikolai B2018-05-141-9/+0
| | | | | | After #449 was merged math can be done on these nodes, adding a test file to unit test all the math operators.
* Make `Arel::Test` subclass of `ActiveSupport::TestCase`Yasuo Honda2018-05-015-70/+74
| | | | | | | | | | not `Minitest::Test` to address `CustomCops/RefuteNot` and `CustomCops/AssertNot` offenses for Arel test cases Also including `ActiveSupport::Testing::Assertions` to `Arel::Spec` and add test/unit backwards compatibility methods Fixes #32720
* Arel: rubocop -aMatthew Draper2018-02-2432-307/+333
|
* Merge Arel into Active RecordMatthew Draper2018-02-2432-0/+1361