Fork me on GitHub
#clojure
<
2015-07-28
>
danielcompton00:07:48

@bjarnagin: with the caveat that you won’t be protected from SQL injection if you do that

colin.yates00:07:51

@danielcompton: Good call out. I use replace for things like replacing the table name or an alias but I still use the parameter list for user injected variables. Yeah, I would never inject user-provided strings into sql.

bjarnagin00:07:25

@danielcompton: fortunately i won’t be accepting user inputs here. i am just making a quick ETL job to process data from multiple client databases and wanted a convenient way to query each db in turn without opening a new connection or going to the effort of sending a USE DATABASE query.

jprudent06:07:17

Hi! Someone mentioned me a clojure lib to request datastructures (ala get-in but much more sophisticated) and I can't find the name again. Do you know it ?

ul06:07:17

There are several of them, https://github.com/clojurewerkz/balagan is on top of my mind.

txus09:07:44

hi! I have a question… if I have a vector [1 2 3] and I want [2 3 1], something like (-> v cycle (drop 1) (take 3)) but without having to know the length… any ideas?

txus09:07:04

shifting all the elements to the left in a way

colin.yates09:07:49

@txus (let [[f & r] [1 2 3]] (conj (vec r) f))

colin.yates09:07:20

@txus - it seems a strange request though; maybe I have misunderstood?

txus09:07:20

no, that’s it simple_smile it just doesn’t work with empty vectors, but it’s okay @colin.yates. thank you a lot

txus09:07:28

I'm literally asking for a friend

txus09:07:35

so I’m not sure what he’s up to

colin.yates09:07:49

np - glad to help

cfleming10:07:07

Am I correct in thinking that in a multi-module project, lein test will run tests from all sub-projects, not just the top-level one?

jprudent10:07:16

@ul: thanks ! specter was the one I had in mind

Lambda/Sierra13:07:44

@cfleming: Leiningen has no built-in support for multi-module projects. Modules are handled by plugins such as lein-sub or lein-modules, and they determine the behavior.

jonpither13:07:25

Anyone used Gloss in anger in here?

ljosa14:07:43

@jonpither: I tried. I implemented the redis protocol using gloss and aleph (largely based on code I fished out of old versions of aleph; it used to have a redis protocol implementation). It ended up being very slow.

cfleming14:07:54

@stuartsierra: Right, but from what I can tell, lein test finds all namespaces on the classpath using bultitude - I don’t know whether that includes tests from dependencies or not. Thinking about it, I guess not, since at that point your sub-module deps are just like any other lib.

cfleming14:07:48

And probably don’t include test nses in their jars.

ds30014:07:39

@ljosa: due to gloss producing inefficient (de)serialization logic? Or something else?

ljosa15:07:11

@ds300: as far as I could tell, yes. (but I could be wrong.) It got very noticeable in requests that were doing hundred of pipelined HGETALLs, each with a dozen fields. (Carmine was much faster but still too slow for my need; I ended up using Jedis, which was still slower than the python redis library that we’ve been using.)

cfleming16:07:37

So I feel like I should know this, but I don’t. Is there a way to test if something is sequable?

cfleming16:07:13

seq will perform various conversions but fails if it can’t produce one, so it’s not so good as an idiomatic check.

cfleming16:07:31

seq? only checks if something actually is an ISeq

ghadi16:07:41

perhaps consider if a protocol can get you out of the game of type-testing?

ghadi16:07:09

("just write a distributed map-reduce function" ... )

cfleming16:07:00

Well, in this case there are various other tests I could use since I’m only working on a known subset of classes, and I think the sequable ones all implement ISeqable, but it seems like something there ought to be a generic check for.

cfleming16:07:25

And in a way, a test like “can this thing be converted into a seq of some kind” really does get out of the type testing to a much greater extent than what seem to be the current options.

chris16:07:55

there is a seqable? in core.incubator

cfleming16:07:38

@chris: Interesting, thanks

cddr18:07:30

I'm debugging a hairy SSL problem. How can I get cider to take me to Java sources?

cddr18:07:47

As in some class in src.zip

denik19:07:00

how can I do a nil or empty / seq condition in a sql korma query?

jamesmintram20:07:19

Hey everyone - I seem to be getting an error when trying to run “lein repl”

Caused by: java.lang.RuntimeException: Unable to resolve symbol: create in this context
I wondered if there was any common solutions to this? (and I hope this is the right place to ask!)

cddr20:07:46

What do you mean @denik? What's the query you'd like to write?

denik20:07:14

@cddr: I got it, was an issue w/ a wrapper I wrote around korma and macros

Lambda/Sierra20:07:21

@jamesmintram: That kind of error is caused by a use of a symbol (`create` in this case) before it has been defined. It is happening when you run lein repl because something else is trying to load the Clojure source file containing that bad code, perhaps from a user.clj file. The solution is to search your code for instances of create that are not defined.

jamesmintram20:07:57

Thanks stuart - this error only occurs when I add a dependency (amazonica) - I think I have just found a work around (exclude com.fasterxml.jackson.core/jackson-databind) - doesn’t seem a great solution though..

aengelberg20:07:41

I see [project-name :scope "test"] in Clojure dependencies a lot, but I can't find it documented anywhere (the :scope keyword). Is this a feature specific to boot (I see it in boot projects primarily)? What does it do?

Lambda/Sierra20:07:00

@jamesmintram: I admit, I'm not sure how adding a dependency would cause that problem, but it might have something to do with dependency conflicts or a bug in that library.

mahinshaw20:07:58

@aengelberg: It's part of maven.

curtosis20:07:36

probably-stupid liberator question... I'm sending a map in the body of a POST request... how do I get it back to a map in my handler?

curtosis20:07:50

(I figure there are more likely liberator folks here than in #C053AK3F9 ...)

aengelberg20:07:44

@mahinshaw Thanks, I wasn't sure because it's not documented in sample.project.clj.

mahinshaw20:07:46

@aengelberg: I hear ya, it took some digging for me to figure that out as well. Looks like @martinklepsch was better about giving you useful feedback though.

martinklepsch20:07:22

@mahinshaw: @aengelberg I think in Leiningen people usually use :dev :dependencies.

mahinshaw20:07:19

@martinklepsch: I think so too. I picked up boot a few months ago, and ran into this. I actually prefer the boot way, although I don't see why you couldn't use the same notation in lein, since it is using maven as well

aengelberg20:07:58

So it's usually used in boot because boot doesn't have a convenient notion of profiles as lein does?

martinklepsch20:07:01

You can totally use it (I believe) it’s just less common

mahinshaw20:07:38

@aengelberg: Nice thing about boot is, you don't really need the dev profile. The tasks take care of that.

aengelberg20:07:02

That satisfies my curiosity. Thanks guys.

bjarnagin21:07:18

I have a query template stored in a file with format specifiers for variables i need to pass in. i’m slurping that file into my program, but when i call format on it, i get a java.util.MissingFormatArgumentException, even though the format arguments are in the file. Am I doing something wrong here?

curtosis23:07:22

any postgresql + yesql wizards around?

cddr23:07:59

Not a wizard but I might be able to help you @curtosis

curtosis23:07:43

I think I found what was going wrong... kept getting a "no operator found for text = jsonb" error.

curtosis23:07:31

in the middle of a SELECT WHERE IN query

cddr23:07:59

You can cast using the ::some_type syntax in yesql

curtosis23:07:25

turned out I was passing in a list of maps where I thought it was a list facepalm

curtosis23:07:45

blah blah static typing.... 😉