This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-06
Channels
- # adventofcode (112)
- # announcements (6)
- # beginners (197)
- # boot (3)
- # calva (52)
- # cider (25)
- # clara (14)
- # cljdoc (6)
- # clojure (147)
- # clojure-austin (6)
- # clojure-berlin (7)
- # clojure-brasil (2)
- # clojure-europe (3)
- # clojure-india (4)
- # clojure-italy (8)
- # clojure-new-zealand (2)
- # clojure-nl (7)
- # clojure-russia (7)
- # clojure-spec (29)
- # clojure-uk (63)
- # clojurescript (103)
- # core-async (5)
- # cursive (11)
- # datomic (16)
- # devcards (1)
- # emacs (28)
- # figwheel-main (3)
- # fulcro (97)
- # graphql (4)
- # hyperfiddle (1)
- # jobs (1)
- # kaocha (3)
- # lumo (9)
- # nrepl (4)
- # off-topic (29)
- # onyx (1)
- # pathom (4)
- # pedestal (8)
- # re-frame (24)
- # reagent (1)
- # reitit (13)
- # ring-swagger (7)
- # rum (11)
- # shadow-cljs (79)
- # sql (46)
- # tools-deps (67)
- # yada (8)
if you want to use pg embedded for testing: I have had some success with com.opentable.components/otj-pg-embedded
A conversation starter http://corfield.org/blog/2018/12/06/null-nilable-optionality/
I like where you're going with this train of thought 🙂
if i intentionally do select a,b,c from table; ... and you'll give me a map which doesn't contain b because it was null ... i will be a very sad puppy
and you will confuse the heck out of oracle customers probably as well
since the empty varchar being a null is an evergiving gift over there
But (:b row)
will still give you nil
just as it does today 🙂
yes but contains will differ as you pointed out
Your point is well taken tho' and speaks to a tension between Clojure's view of optionality and SQL's view of it.
it's a tricky place, clash of two worlds 🙂 ... and sometimes the "good old standardized sql world" is quite a mess of it's own
Indeed. Maybe the omission of NULL
will end up being the default but with an option not to do that in the new API?
just as a crazy example -> https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8.html
once upon a time i was very much invested into mysql ... and never knew about their funny utf8 definition ... only learned about it a year ago (but i have been in bed with postgresql since 2006 and haven't looked back anyway)
As a very heavy user of MySQL, who just went through the pain of a MySQL 5.5 to Percona 5.7 migration, I definitely feel the UTF8 issues!
(ns theapp (:require [clojure.java.jdbc :as jdbc] [java-jdbc.ddl :as ddl])) (def db-spec {:dbtype "pgsql" :dbname "dbname" :user "user"}) (jdbc/query db-spec ["SELECT * AS result"])
where should the psql driver fit into that?
I know that's probably mangled.
your dbtype looks funny
(def pg-source-db {:dbtype "postgresql"
:dbname "test_source_db"
:host "127.0.0.1"
:port 5432
:user "shop_user"
:password "i_always_paste_passwords_in_slack"})
FYI, :port
and :host
have those default values for "postgresql"
Also "postgres"
is accepted as a shorthand for "postgresql"
🙂
@macrobartfast You need to provide the PostgreSQL JDBC driver as a dependency, the same way you provide org.clojure/java.jdbc
as a dependency (in project.clj
or deps.edn
or wherever).
@macrobartfast if you use leiningen then a dep like this
[org.postgresql/postgresql "42.2.5"]
The readme at https://github.com/clojure/java.jdbc links to Maven for all the JDBC drivers, and https://github.com/clojure/java.jdbc/blob/master/deps.edn#L9-L19 shows the driver versions that I test against while developing java.jdbc
.
sweet! thank you!
I wouldn't recommend using java-jdbc.ddl
(even tho' I wrote it) -- it's unmaintained. create-table-ddl
and drop-table-ddl
are already built into clojure.java.jdbc
so you don't need that extra library.
(and the syntax for create index is trivial enough not to need a DDL generator)
If you want a DSL for your SQL, for composable queries etc, I would recommend #honeysql (which we use heavily at work -- and so I've recently started maintaining that too). @macrobartfast
:thinking_face:wondering here, have you seen a tool out there that manages sql tables as table definition states ? (not migrations from a to b but actual states of definition)
awesome... I'll use honeysql. should a noob like me start without honeysql, or get used to using it from the start?
my queries now are along the lines of 'select * from fruit'.
never mind that last question... too vague. I'll start without a dsl and move to honeysql for the learning/future-ability within a day.
I'm talking to my db! 😊
so fun to do with a repl.
little bobby tables...
We use a REPL into our production processes to run JDBC code, rather than a SQL command line 🙂
regarding the null -> omit key-value topic , if you declare a new version of the api that doesn't clash with the old one (and describe the behavior in the docs) , i really don't see a problem for new users
@seancorfield awesome, and terrifying.
but when i just peeked at my own code from a week ago, i actually occasionally iterated over the keys of the result hashmaps and expected the keys to be present
I'm looking at making reducible-query
kind of the first class entry point (for the R in CRUD) and using the raw result set approach -- a thin reify
d wrapper over ResultSet
-- so "iterating over the keys" is something I'm going to need to figure out anew anyway.
and probably i'm not the only one
@seancorfield but I guess no more so than the SQL cli.
but my clumsy cider mis-evaluations in a buffer full of statements could be, uh, fun.