Fork me on GitHub
#sql
<
2018-12-06
>
mpenet14:12:44

if you want to use pg embedded for testing: I have had some success with com.opentable.components/otj-pg-embedded

mpenet14:12:22

quite easy to use and not horribly slow

shaun-mahood23:12:41

I like where you're going with this train of thought 🙂

kulminaator20:12:26

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

kulminaator20:12:15

and you will confuse the heck out of oracle customers probably as well

kulminaator20:12:27

since the empty varchar being a null is an evergiving gift over there

seancorfield20:12:10

But (:b row) will still give you nil just as it does today 🙂

kulminaator20:12:34

yes but contains will differ as you pointed out

seancorfield20:12:40

Your point is well taken tho' and speaks to a tension between Clojure's view of optionality and SQL's view of it.

kulminaator20:12:27

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

seancorfield20:12:39

Indeed. Maybe the omission of NULL will end up being the default but with an option not to do that in the new API?

kulminaator20:12:58

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)

seancorfield20:12:46

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!

macrobartfast20:12:31

(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"])

macrobartfast20:12:54

where should the psql driver fit into that?

macrobartfast20:12:42

I know that's probably mangled.

kulminaator20:12:44

your dbtype looks funny

kulminaator20:12:34

(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"})

seancorfield20:12:41

FYI, :port and :host have those default values for "postgresql"

seancorfield21:12:26

Also "postgres" is accepted as a shorthand for "postgresql" 🙂

seancorfield20:12:54

@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).

kulminaator20:12:44

@macrobartfast if you use leiningen then a dep like this

[org.postgresql/postgresql "42.2.5"] 

seancorfield20:12:13

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.

macrobartfast21:12:28

sweet! thank you!

seancorfield21:12:59

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.

seancorfield21:12:22

(and the syntax for create index is trivial enough not to need a DDL generator)

seancorfield21:12:41

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

kulminaator21:12:09

: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)

macrobartfast21:12:09

awesome... I'll use honeysql. should a noob like me start without honeysql, or get used to using it from the start?

macrobartfast21:12:41

my queries now are along the lines of 'select * from fruit'.

macrobartfast21:12:46

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.

seancorfield21:12:55

I would avoid DSLs until you're up and running for a while.

👍 4
macrobartfast21:12:35

I'm talking to my db! 😊

macrobartfast21:12:21

so fun to do with a repl.

macrobartfast21:12:36

little bobby tables...

seancorfield21:12:18

We use a REPL into our production processes to run JDBC code, rather than a SQL command line 🙂

kulminaator21:12:31

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

macrobartfast21:12:18

@seancorfield awesome, and terrifying.

kulminaator21:12:18

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

seancorfield21:12:35

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 reifyd wrapper over ResultSet -- so "iterating over the keys" is something I'm going to need to figure out anew anyway.

kulminaator21:12:25

and probably i'm not the only one

macrobartfast21:12:55

@seancorfield but I guess no more so than the SQL cli.

macrobartfast21:12:40

but my clumsy cider mis-evaluations in a buffer full of statements could be, uh, fun.

kulminaator21:12:05

google for dba-s with scissors, you'll be fine 😄

😂 4