mirror of
https://github.com/dimitri/pgloader.git
synced 2026-02-26 08:41:02 +01:00
This fixes #308 by automatically using the PostgreSQL Client Side SSL files as documented in the following reference: http://www.postgresql.org/docs/current/static/libpq-ssl.html#LIBPQ-SSL-FILE-USAGE This uses the Postmodern special support for it. Unfortunately couldn't test it locally other than it doesn't break non-ssl connections. Pushing to have user feedback.
57 lines
1.7 KiB
Common Lisp
57 lines
1.7 KiB
Common Lisp
;;;
|
|
;;; Random utilities
|
|
;;;
|
|
(in-package :pgloader.utils)
|
|
|
|
;;;
|
|
;;; Camel Case converter
|
|
;;;
|
|
(defun camelCase-to-colname (string)
|
|
"Transform input STRING into a suitable column name.
|
|
lahmanID lahman_id
|
|
playerID player_id
|
|
birthYear birth_year"
|
|
(coerce
|
|
(loop
|
|
for first = t then nil
|
|
for char across string
|
|
for previous-upper-p = nil then char-upper-p
|
|
for char-upper-p = (eq char (char-upcase char))
|
|
for new-word = (and (not first) char-upper-p (not previous-upper-p))
|
|
when (and new-word (not (char= char #\_))) collect #\_
|
|
collect (char-downcase char))
|
|
'string))
|
|
|
|
;;;
|
|
;;; Unquote SQLite default values, might be useful elsewhere
|
|
;;;
|
|
(defun unquote (string &optional (quote #\'))
|
|
"Given '0', returns 0."
|
|
(declare (type (or null simple-string) string))
|
|
(when string
|
|
(let ((l (length string)))
|
|
(if (char= quote (aref string 0) (aref string (1- l)))
|
|
(subseq string 1 (1- l))
|
|
string))))
|
|
|
|
;;;
|
|
;;; Process ~/ references at run-time (not at compile time!)
|
|
;;;
|
|
(defun expand-user-homedir-pathname (namestring)
|
|
"Expand NAMESTRING replacing leading ~ with (user-homedir-pathname)"
|
|
(typecase namestring
|
|
(pathname namestring)
|
|
(string
|
|
(cond ((or (string= "~" namestring) (string= "~/" namestring))
|
|
(user-homedir-pathname))
|
|
|
|
((and (<= 2 (length namestring))
|
|
(char= #\~ (aref namestring 0))
|
|
(char= #\/ (aref namestring 1)))
|
|
(uiop:merge-pathnames*
|
|
(uiop:parse-unix-namestring (subseq namestring 2))
|
|
(user-homedir-pathname)))
|
|
|
|
(t
|
|
(uiop:parse-unix-namestring namestring))))))
|