Fork me on GitHub
#sql
<
2021-11-03
>
pyr20:11:05

Hi! I am in need of providing my own :qualifier-fn and :label-fn opts to next.jdbc but I would need to know of the result of qualifier-fn when label-fn is called. It seems to me that's not possible with the current API, but maybe I'm doing things wrong?

seancorfield20:11:59

@pyr Can you explain what problem you are trying to solve?

pyr20:11:38

In seql there is a facility to describe schemas, mapping to fully qualified entities

pyr20:11:04

which allows you for instance to say (query :my.entities.account [:my.entities.account/name])

pyr20:11:18

so far so good, that's easy enough to do with qualifier-fn and label-fn

pyr20:11:35

I went for the same good default of using camel-snake-kebab for label-fn

pyr20:11:05

but in the odd case, the conversion that csk does might not map to the actual column name in the underlying seql schema

pyr20:11:14

to that effect I added a way in the schema specification to specify the column name

pyr20:11:12

I don't yet see how to handle that straight from qualifier-fn/label-fn

pyr20:11:32

and wanted to see if I could avoid doing any post-processing

pyr20:11:47

(but worst comes to worst, I'll resort to that)

seancorfield20:11:49

OK, so probably best plan of attack is to write your own variant of next.jdbc.result-set/get-modified-column-names and then your own version of next.jdbc.result-set/as-modified-maps and use that as your builder. It's only a few lines of code (and you could even do it in one function).

seancorfield20:11:35

I would advise using your own option key if you need one, rather than confusing people by reusing qualifier-fn/label-fn but with different meanings.

pyr20:11:19

thanks for the pointers. you're right I was starting from as-modified-maps

seancorfield20:11:28

It sounds like you need a builder that is specific to seql anyway?

pyr20:11:35

(mostly out of lazyness I guess :-))

pyr20:11:58

yes I provide a builder-fn that uses as-modified maps

pyr20:11:05

I'll go on to doing that then, thanks!

pyr20:11:27

Hoping get my latest PR in later this week

pyr20:11:35

some pretty cool things coming up and now I rely more on next.jdbc

1