Fork me on GitHub
#malli
<
2020-04-02
>
ikitommi14:04:28

fixed a bug on collection type transformations, which turned maps into vectors. Will push a new SNAPSHOT to clojars as need it with reitit (which uses leiningen)

dcj16:04:51

Presumably mailli schema properties are open? So I can specify a (new) key, that I use for my own purposes? Example: assign :postgres/type "some-postgres-type", later I walk schema and "make it so" via connection to database?

dcj20:04:43

Apparently so, a test schema for a database table:

(def metadata-schema
  [:map {:postgres/schema "slm"
         :postgres/table "measurement_metadatas"}
   [:id {:postgres/type :bigserial
         :postgres/key  :primary} int?]
   [:instrument-id {:postgres/type :bigint
                    :postgres/null? false} int?]
   [:datafile-id   {:postgres/type :bigint
                    :postgres/null? false} int?]
   [:seq           {:postgres/type :integer
                    :postgres/null? false} int?]
   [:origin        {:postgres/type :float8
                    :postgres/null? false} double?]
   [:scale         {:postgres/type :float4
                    :postgres/null? false} float?]
   [:starting-timestamp {:postgres/type :timestamptz
                         :postgres/null? false} inst?] ;; TODO: fix
   [:sample-rate   {:postgres/type :float4
                    :postgres/null? false} float?]
   [:log-interval  {:postgres/type :float4
                    :postgres/null? false} float?]
   [:weighting     {:postgres/type :text
                    :postgres/null? false} string?]
   [:manifest      {:postgres/type :int
                    :postgres/null? false} int?]
   [:time-zone     {:postgres/type :int
                    :postgres/null? false} int?]])
And, as a quick experiment, wrote fn to print DDL text driven by the above, yielding:
CREATE TABLE slm.measurement_metadatas (
    id bigserial PRIMARY KEY,
    instrument_id bigint NOT NULL,
    datafile_id bigint NOT NULL,
    seq integer NOT NULL,
    origin float8 NOT NULL,
    scale float4 NOT NULL,
    starting_timestamp timestamptz NOT NULL,
    sample_rate float4 NOT NULL,
    log_interval float4 NOT NULL,
    weighting text NOT NULL,
    manifest int NOT NULL,
    time_zone int NOT NULL
    );

🎉 8
dcj20:04:11

Is there (should there be) a long? predicate in malli?