This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn d-mask-col! | |
[table col rule] | |
(let [colfn (rule table col)] | |
(when (fn? colfn) | |
(let [raw-vals (db/distinct-values table col) | |
non-nil-vals (remove nil? raw-vals) | |
old-new-vals (map (juxt identity colfn) non-nil-vals) | |
c-path (db/path col) | |
execute #(apply sql/do-prepared % old-new-vals) | |
using-comparison #(format "update %s set %s = ? where %s %s ?" (db/path table) c-path c-path %)] | |
(println "Masking" (count non-nil-vals) "value(s) of" (db/path table col)) | |
(try | |
(execute (using-comparison "=")) | |
(catch Exception e | |
(if (text-type-fail? e) | |
(execute (using-comparison "like")) | |
(throw e)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment