Fork me on GitHub
#babashka
<
2023-01-03
>
danielgrosse13:01:39

Hello, I'm actually experimenting with database access and struggled with a case sensitive column name. When running (pg/execute! db ["select columValue from table"]) an exception is thrown stating: ERROR: column "columvalue" does not exist I already looked into the documentation of next.jdbc but haven't found a solution to keep the casing.

borkdude13:01:22

Is this using the postgresql pod?

borkdude13:01:09

Have you tried using regular jvm jdbc to see if there's a difference?

borkdude13:01:05

It might be best to to try this for debugging since the postgres pod might be a bit behind on the version of next.jdbc

danielgrosse13:01:24

But then I can't use Babashka for it?

borkdude13:01:38

I wouldn't know why a raw sql query might have capitalization problems, but it would be interesting to see if the JVM version also has this problem

dharrigan13:01:47

How was the table/column created?

dharrigan13:01:55

can you show the DDL?

danielgrosse13:01:38

CREATE TABLE table (
  "id" serial,
  "columValue" text NOT NULL
) ;

danielgrosse13:01:49

It is part of a different service.

dharrigan13:01:01

Columns that are created using double quotes must be double quoted for all their life...

👀 2
👍 2
dharrigan13:01:22

Quoting an identifier also makes it case-sensitive, whereas unquoted names are always folded to lower case. For example, the identifiers FOO, foo, and "foo" are considered the same by PostgreSQL, but "Foo" and "FOO" are different from these three and each other. (The folding of unquoted names to lower case in PostgreSQL is incompatible with the SQL standard, which says that unquoted names should be folded to upper case. Thus, foo should be equivalent to "FOO" not "foo" according to the standard. If you want to write portable applications you are advised to always quote a particular name or never quote it.)

danielgrosse13:01:29

Yes your right. Thanks for the explanation

dharrigan13:01:59

You're most welcome! 🙂

jkrasnay15:01:20

I’m getting this error in my editor (Neovim), but I think it’s a problem with my Babashka install (via homebrew)

LSP[clojure_lsp] Classpath lookup failed when running `/opt/homebrew/bin/bb print-deps --format classpath`. Some features may not work
properly.

jkrasnay15:01:13

When I run bb print-deps --format classpath I get this:

Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main
Exception in thread "main" java.io.FileNotFoundException: /Users/john/.clojure/.cpcache/EC75370BCEABA1C0496F6D9CBE1EC430.cp (No such file or directory)

jkrasnay15:01:35

I’ve tried deleting my ~/.clojure/.cpcache but it doesn’t help.

lispyclouds15:01:08

do you happen to have a .cpcache in the dir youre in as well?

jkrasnay15:01:17

And I get a similar error regardless of the directory, although sometimes the specific missing filename is different.

borkdude15:01:22

@U0DTSCAUU Just for debugging, can you try:

bb --force print-deps --format classpath

jkrasnay15:01:27

Produces the same error with --force

borkdude15:01:35

and what about just bb?

jkrasnay15:01:35

bb and bb print-deps both work fine.

borkdude15:01:35

aha, so it's the --format classpath specifically

borkdude15:01:57

which bb version

borkdude15:01:57

what happens when you do:

bb clojure -Spath -Sdeps "$(bb print-deps)" 

borkdude15:01:38

(I expect the same error)

jkrasnay15:01:39

Well, different missing filename, but still FileNotFoundException

borkdude15:01:11

this is interesting, now perhaps you can bisect the contents of bb print-deps until you have something that works and doesn't work

borkdude15:01:29

does just bb clojure -Spath work?

borkdude15:01:29

did you erase your .m2 directory or so?

borkdude15:01:40

or perhaps some file permission thing?

jkrasnay15:01:08

No, I haven’t done anything manually to my .m2

borkdude15:01:47

Can you try:

bash <(curl -s ) --dir /tmp --dev-build
and then try again with /tmp/bb clojure -Spath?

jkrasnay15:01:32

That works fine.

borkdude15:01:01

and with print-deps classpath?

jkrasnay15:01:24

Yep, that works. Interestingly, bb clojure -Spath now works (my homebrew-installed bb, not the one in tmp), so something has changed, but bb print-deps --format classpath is still broken.

borkdude15:01:44

don't know, without an exact copy of your hard disk... but I'll release a new bb this week or so, so maybe you can use the dev build until then

borkdude15:01:04

you could try to debug this with a local checkout of deps.clj

borkdude15:01:21

clojure -M -m borkdude.deps -Spath -Sdeps "$(bb print-deps)"

jkrasnay15:01:39

~/ws/deps.clj [master]
λ clojure -M -m borkdude.deps -Spath -Sdeps "$(bb print-deps)"
Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main
src:resources:/Users/john/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar:/Users/john/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar:/Users/john/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar

jkrasnay15:01:54

I think something’s wrong with my Clojure install.

borkdude15:01:28

Maybe you can wipe /Users/john/.m2/repository/org/clojure/clojure/1.11.1

jkrasnay15:01:44

Although this works, using same classpath as above:

λ java -cp /Users/john/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar:/Users/john/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar:/Users/john/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar clojure.main
Clojure 1.11.1
user=>

jkrasnay15:01:58

OK, I’ll try that…

jkrasnay16:01:05

I’ve wiped 1.11.1 from my .m2 and re-run clojure -M -m borkdude.deps -Spath -Sdeps "$(bb print-deps)". On the first run I see it downloading the new Clojure JARs but the error still occurs, even on subsequent runs.

borkdude16:01:43

ok, so if you check out deps.clj locally you could try inserting some printlns, etc to check what's going on

dpsutton16:01:01

how did you install clojure? And do you have a clj program?

borkdude16:01:50

this should not be very relevant to bb btw

👍 2
jkrasnay16:01:02

I installed Clojure via homebrew (btw macos Ventura on MBA M2)

borkdude16:01:29

did you use the clojure tap rather than the homebrew package?

jkrasnay16:01:18

I seem to recall seeing the error after I upgraded to Clojure 1.11.1.1208 from some previous version of 1.11.1.

jkrasnay16:01:34

…although it didn’t really bite me until now

jkrasnay16:01:05

I’m not sure re “tap” vs “homebrew package”. Does this answer the question?

λ brew info clojure
==> clojure: stable 1.11.1.1208 (bottled)

borkdude16:01:05

that seems legit

jkrasnay16:01:42

Another data point: bb print-deps had stopped working. It was throwing ClassNotFoundException for clojure.main, which is why clojure -M -m borkdude.deps -Spath -Sdeps "$(bb print-deps)". I changed bb to /tmp/bb , which worked, but it also fixed bb print-deps. The above clojure -M… command now works.

jkrasnay23:01:48

@U04V15CAJ it appears the upgrade to 1.0.169 has somehow fixed my problem. Thanks for your help!

🎉 2