Advertisement
Guest User

Untitled

a guest
Aug 25th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;; Events Schema
  2. CREATE TABLE events
  3.     (
  4.         event_id          serial        ,
  5.         title             text          NOT NULL,
  6.         description       text          NOT NULL,
  7.         photographers         int[]         ,
  8.         tags              int[]         ,
  9.         CONSTRAINT event_pk PRIMARY KEY(event_id)
  10.     );
  11.  
  12. ;; Notice that photographers and tags are integer ARRAY postgresql types.
  13.  
  14. ;; Insert new event into 'events' table.
  15. (sql/insert! db
  16.      :events {
  17.          :title "My title"
  18.          :description "A longer description here"
  19.          :photographers [1 2 3]
  20.          :tags ["tag1" "tag2" "tag3"]
  21.      })
  22.  
  23. ;; Another futile attempt, declaring a list, same error
  24. (sql/insert! db
  25.      :events {
  26.          :title "My title"
  27.          :description "A longer description here"
  28.          :photographers (list 1 2 3)
  29.          :tags (list "tag1" "tag2" "tag3")
  30.      })
  31.  
  32. ;;org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of clojure.lang.PersistentVector. Use setObject() with an explicit Types value to specify the type to use.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement