Closed jgaskins closed 7 years ago
This is awesome, thanks!
It looks like CI is failing because of rubocop
. Could you run rubocop -aD
locally and make sure that it passes?
UUGGGGHH this pushes it just past the threshold of so many things Rubocop tracks! :-)
Lemme see what I can do here.
The Metrics/ClassLength
is a larger issue which I can probably attack if it's taking too much time ;)
@cheerfulstoic haha I was just taking another look at this. I couldn't figure out a way to make the class smaller without more refactoring than I'm comfortable doing here and was about to ask if we should just bump the threshold up a notch. :-)
Regarding the Style/AlignParameters
cop, I figured I could either inline the whole thing (makes it look more like the other examples but hard to see the params at a glance) or pull one of these maneuvers:
describe '.where(q: { created_at: Date.new(2017, 6, 1)..Date.new(2017, 6, 3) })' do
it_generates(
'WHERE (q.created_at >= {q_created_at_range_min} AND q.created_at <= {q_created_at_range_max})',
q_created_at_range_min: Date.new(2017, 6, 1),
q_created_at_range_max: Date.new(2017, 6, 3)
)
… which makes it a bit easier to read but then it's nothing like the rest.
Yeah, the QueryClauses
module is a beast ;) . I'll merge and have a look at it now
Working on this and I just did 10 trials each comparing IN RANGE()
to x <= y AND y <= z
and found that the latter was much faster, so that should simplify the code (I'm doing that now):
WITH RANGE(1, 5000) AS list
UNWIND list as i
RETURN i IN RANGE(1500, 3500)
1375 ms
1018 ms
1002 ms
970 ms
1047 ms
1090 ms
997 ms
990 ms
953 ms
1030 ms
WITH RANGE(1, 5000) AS list
UNWIND list as i
RETURN 1500 <= i AND i <= 3500
73 ms
89 ms
64 ms
59 ms
78 ms
47 ms
78 ms
65 ms
76 ms
83 ms
Just released 7.2.0
of the neo4j-core
gem with this addition. Thanks again!
Awesome! 👍 Glad I could help!
Passing a time or date range wasn't working when serialized as non-integer values (I've been using strings for query readability) for two reasons:
RANGE
functionRange#max
doesn't work for non-integer values when the range excludes the high endThis commit expands support for ranges to include non-numeric ranges and non-integer exclusive ranges through the use of
Range#end
rather thanRange#max
. It leaves integer-range support alone in case Neo4j has internal optimizations for it. I also included a spec for the float-range exclusive case and confirmed it raised aTypeError
before making any changes to thelib
code.Pings: @cheerfulstoic (seems to have the most commits on this file)