| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|\
| |
| | |
Unused variable
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
|
| |
When an Arel AST contains a SelectManager as a component, e.g. as a CTE
expression, the SelectManager is converted to SQL with `#to_sql`. This
uses a new collector that leads to invalid expressions when using
bind parameters. For example, when generating PostgreSQL queries, the
bind parameter number starts from one again. When using the
SubstituteBinds collector, binds in the subquery are not substituted.
This commit changes the ToSql visitor to visit the SelectManager ast
itself.
|
| |
|
|
|
|
|
|
|
| |
Fixes warning in Rails tests:
```
/home/travis/build/rails/rails/vendor/bundle/ruby/2.4.0/bundler/gems/arel-b9ca36f09d5e/lib/arel/visitors/oracle.rb:32: warning: assigned but unused variable - offset_bind
``
|
|
|
|
|
|
| |
Here `offset` is bound twice. It used to be `:b1` appeared twice.
This commit changes the second `offset` name changed from `:b1` to `:b3`
which should not affect the actual bind values for offset.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Some of the nodes classes are missing either one or many of the common comparison methods #hash, #eql? and #==.
This makes comparision and working with the ast sometimes painful, as equality or operations likes array differences (which uses a hash behind the scene) produces unexpected results.
A test has been added that ensures that every descendants of Node:
* have all 3 methods
* that all 3 methods were defined from the same class
* that the class defining all 3 is also a descendant of Node, to avoid the default ones that rely on identity only
|
|
|
|
|
| |
Since https://github.com/rails/rails/commit/213796f, `bind_values` is no
longer used from Active Record.
|
|
|
|
|
|
|
|
|
|
| |
We need `value` to have a writer for `StatementCache` to work when
prepared statements are disabled. This is something I'd like to revert
eventually, either by disabling that form of caching in that case or
re-introducing something like the old `Bind` collector.
The addition of `nil?` is to make `IS NULL` be inserted correctly,
similar to what we already do with quoted and casted nodes
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|\
| |
| | |
Support INSERT with multiple values (v2)
|
| | |
|
|\ \
| |/
|/| |
Make Visitor visit thread safe by holding dispatch method reference
|
| | |
|
| |
| |
| |
| |
| |
| | |
Follow up of 98fc25991137ee09b6800578117f8c1c322680f2.
`engine` is only used for `to_sql` and `where_sql` now.
|
|/ |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
closes #461
|
| |
|
|\
| |
| | |
remove union mapping as :binary node when performing DepthFirst enumeration
|
| | |
|
|\ \
| | |
| | | |
Add Arel::Nodes::Casted to dot visitor
|
| |/
| |
| |
| |
| |
| |
| | |
Adds casted node to the dot visitor with outgoing edges to val and
attribute.
Fixes #419
|
|\ \
| | |
| | | |
Freeze all the strings in visitors
|
| | | |
|
| | | |
|
|/ /
| |
| |
| |
| |
| |
| | |
The aliases property of a table is never used other than for equality. However,
the aliases that have been created for a table aren't really something that
should affect whether a table is considered to be the same table or not. This
removal does not appear to have any affect within Active Record or within Arel.
|
|/
|
|
|
|
| |
Since BindParam contains no information, treating it like a string
adds no useful information to the graph, and results in an invalid
label format.
|
| |
|
|
|
|
| |
There is no @class variable.
|
| |
|
|\
| |
| | |
Fix issue #415 - Should Arel::Nodes::True.new() be 1 in sqlite3?
|
| | |
|
|\ \
| | |
| | | |
DRY up visit_Arel_Nodes_SelectCore
|
| | |
| | |
| | |
| | | |
collect_nodes_for, for collecting wheres, projections, groups, windows
|
| | |
| | |
| | |
| | | |
[ci skip]
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005
Ruby ~2.3 `1234.class` is `Fixnum` and `123456789012345678901234567890.class`
is `Bignum`.
Ruby 2.4+ `1234.class` is `Integer` and `123456789012345678901234567890.class`
is `Integer`.
So what we should do is defining `visit_Integer` method to visitors.
|
|\ \ \
| | | |
| | | | |
Support Oracle bind parameter value for Oracle12 visitor
|