Fork me on GitHub
quan xing02:09:20

How can I pagination mysql's data in Clojure


When fetching? By using sql LIMIT and OFFSET


Or by using an sql CURSOR


If these don’t meet your needs, we could use more details on your use case @imxingquan

quan xing07:09:49

yes by By using sql `LIMIT` and `OFFSET` . Should I need to write 2 sql 'select count' and 'select limit', shouldn't I?

👍 1

Or check the number of results you're getting back. Depends what you're doing with it


Tis a bad idea, generally to use LIMIT and OFFSET for doing pagination, it becomes a bigger bigger problem for larger and larger result sets

quan xing08:09:15

Is there a good way to solve this problem

Ed08:09:45 ... Mysql will let you get the total number of rows without running the whole query twice.

quan xing09:09:43

wow, thank you @l0st3d.


Hi. is there a method to replace dash by underscore with keywords?


excluding the string/replace


found it : (csk/->snake_case :s3-key :separator \-)


Interesting. Which lib is that, providing ->snake_case?


(def foosym ^{:foo 10} (fn []))
does this not put the meta on the function? Where do I find the meta data when I do it like this?


it puts metadata to the function not the var

(def foosym ^{:foo 10} (fn []))

(meta @#'foosym) ;; => {:foo 10}

Alex Miller (Clojure team)15:09:27

functions (generically) do not support metadata (although some impls do in some cases)

Alex Miller (Clojure team)15:09:25

that is, in impl types, IFn does not extend IMeta


but then why this happen?

(def foosym ^{:foo 10} (fn []))

(meta @#'foosym) ;; => {:foo 10}


But the interface IFn and Fn don't have too. Functions created with (fn ...) are going to be AFunction so that they can have meta which tells you the function name and column/line and all that I believe.


But all other functions not created with fn unless they themselves implements IObj and IMeta won't support metadata.

Alex Miller (Clojure team)15:09:41

> (although some impls do in some cases)

Alex Miller (Clojure team)15:09:30

but I would not generally rely on this

Alex Miller (Clojure team)15:09:57

if you read, it says "Note that metadata reader macros are applied at read-time, not at evaluation-time, and can only be used with values that support metadata, like symbols, vars, collections, sequences, namespaces, refs, atoms, agents, etc."


(defn ^{} foo []) 
is good right? now you I get the mets from the var

Alex Miller (Clojure team)15:09:42

that is the more normal place to put metadata, yes

👍 1

Speaking of interfaces like IFn and IMeta: I often see pertinent mentions of Clojure implementation details (most often interfaces), in in-depth answers to some more advanced questions. Is there a recommended resource (book/site/other) for learning about the most important bits of Clojure's implementation, and how they fit together?

Alex Miller (Clojure team)15:09:56

I do not think that exists anywhere. There are some info and diagrams in Clojure Applied that cover parts of it

Alex Miller (Clojure team)15:09:25

specifically the collection/seq parts


Thanks, @alexmiller. That's the kind of answer I was expecting. 👍

Jim Strieter17:09:17

Is there any way to use Intelli-J/Cursive to generate clojure bindings for a local java projct?

Sam Ferrell18:09:21

How do I discriminate between values like '[:foo 1] and [:foo 1] ?


after evaluation they are the same


user=> ''[:foo 1]
(quote [:foo 1])
before evaluation ' is a reader macro that wraps things in a list where the first item in the list is the symbol quote


usually if you are trying to distinguish the two you are starting to make a mistake with macros

Sam Ferrell18:09:41

Trying to write a function that accepts either a Datomic/Datascript query '[:find ...] or a pull expression against a default query


for a function, functions receive evaluated arguments, in which case '[:foo 1]and [:foo 1] are identical

Sam Ferrell18:09:01

Gotcha, that makes sense