This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-30
Channels
- # announcements (40)
- # babashka (41)
- # beginners (32)
- # calva (15)
- # clara (8)
- # clj-kondo (14)
- # cljs-dev (30)
- # clojure (37)
- # clojure-dev (8)
- # clojure-europe (21)
- # clojure-norway (21)
- # clojure-uk (4)
- # clojured (3)
- # clojurescript (4)
- # community-development (10)
- # core-async (13)
- # cursive (23)
- # datomic (15)
- # emacs (9)
- # fulcro (3)
- # google-cloud (4)
- # graphql (24)
- # gratitude (2)
- # holy-lambda (4)
- # honeysql (5)
- # hyperfiddle (9)
- # keechma (1)
- # klipse (5)
- # lsp (23)
- # malli (4)
- # missionary (32)
- # pathom (28)
- # re-frame (2)
- # reagent (40)
- # reitit (17)
- # releases (2)
- # remote-jobs (1)
- # shadow-cljs (25)
- # specter (3)
- # vim (19)
- # xtdb (41)
Hi ! So, I got this project running on honeysql 1.x and the migration work isn’t scheduled for anytime soon. The code is hooked to a mysql database and I want to use https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html function to get change the timezone of a value using a timezone from a different column. >
SELECT CONVERT_TZ (foo, 'Europe/Oslo','UTC');
How can I achieve that using the raw helper ?Are you looking for something like this:
dev=> (sql/format {:select [(sql/call :convert_tz :foo "Europe/Oslo" "UTC")] :from [:table]})
["SELECT convert_tz(foo, ?, ?) FROM table" "Europe/Oslo" "UTC"]
dev=>
You could specify column names instead of either string. No need to use raw
here.And just for comparison, in v2 you don't need call
-- you can use the "regular" vector form for calls, but because of the possibility of column aliases in :select
, you need extra nesting:
dev=> (sql/format {:select [[[:convert_tz :foo "Europe/Oslo" "UTC"]]] :from [:table]})
["SELECT CONVERT_TZ(foo, ?, ?) FROM table" "Europe/Oslo" "UTC"]
dev=>
because this has to be possible:
dev=> (sql/format {:select [:col1 [:col2 :alias2] [[:convert_tz :foo "Europe/Oslo" "UTC"] :alias3]] :from [:table]})
["SELECT col1, col2 AS alias2, CONVERT_TZ(foo, ?, ?) AS alias3 FROM table" "Europe/Oslo" "UTC"]
dev=>
Does that help @UTQF861NK?