Skip to content

Add position to columns metadata #78

@ahoy-jon

Description

@ahoy-jon

(Proposal)

I think the position information is relevant for columns and could be added to the analyser.
But thank to the extensibility 👍 of the analyser, it can be added without changing lobos.

(def db
     {:subprotocol "mysql"
      :user "admin"
      :password "mypass"
      :subname "//docker:3306/mydb"})

(require '[lobos.schema] '[lobos.analyzer :as an])

(defmethod an/analyze [:mysql lobos.schema.Column] [_ column-meta]   
  (let [std (get-method an/analyze [:lobos.analyzer/standard lobos.schema.Column])
        std-analyzed (std _ column-meta)]
    (assoc std-analyzed :position (:ordinal_position column-meta))))

(->> (an/analyze-schema db) :tables first second :columns first second keys)

;#=> (:cname :data-type :default :auto-inc :not-null :others :position)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions