-
-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More small optimizations #562
Conversation
b2a105d
to
f1b9202
Compare
f1b9202
to
d086631
Compare
I'll take a look when I get back from vacation. |
Took a quick look -- I think you're right: this is a bug in existing HoneySQL code, and it seems like your PR fixes it somehow? Locally: user=> (require '[honey.sql :as sql])
nil
user=> (System/getProperty "java.version")
"1.8.0_332"
user=> (sql/format {:insert-into :table
#_=> :values [[1 2 3] :default [4 5 6]]})
["INSERT INTO table VALUES (?, ?, ?), DEFAULT, (?, ?, ?)" 1 2 3 4 5 6]
user=> (sql/format {:insert-into :table
#_=> :values [{:a 1 :b 2 :c 3}
#_=> :default
#_=> {:a 4 :b 5 :c 6}]})
["INSERT INTO table (a, b, c) VALUES (?, ?, ?), DEFAULT, (?, ?, ?)" 6 5 4]
user=> I get that second, incorrect, result on every JDK locally. |
Here is the bug: Line 1206 in 8e0d698
If params' is nil, it returns params' again (which is nil). It should've been params .
|
There's a reflection warning in
I suspect you'll want to submit a PR to fix that? |
It's not a reflection warnings, but an autoboxing warning, and it doesn't matter that much here. But warnings are annoying, so I'm going to fix this, yeah. |
Thanks. Shows up with |
The first one saves a bit on that regexpy
str/replace
if the keyword already doesn't contain any hyphens. Alternatively, it could be rewritten into some explicit loop that looks for hyphens and then checks if they aren't on the edges of the string, but I don't think the complication is worth it. Checking for present hyphen is easy and quick, and given that most keywords don't have hyphens, this already saves most of what it is there to be saved.The second one is some streamlining of code inside
format-values
. The refactored version tries to do most of work inside thereduce
loop, without pre-processing stuff withmap
first.