caribou / caribou-core

Core functionality for Caribou
44 stars 3 forks source link

Renaming habtm target models breaks #3

Closed miwillhite closed 12 years ago

miwillhite commented 12 years ago

I created a Book, and a Person. Then I linked the two, which created a books_person model.

Next I went back into the Book model and renamed the target model from Person to Reader.

When I went to create an instance of a Book, I got the following error:

db: db:select count(id) from person 
select count(id) from books_person
action: create-content => {:slug "book", :book {:title "Mr. Norrell and Jonathan Strange"}}
org.postgresql.util.PSQLException: ERROR: relation "books_reader" does not exist
  Position: 170
db: insert into book values title = 'Mr. Norrell and Jonathan Strange'
action: item-detail => {:slug "book", :id "1", :include "reader,person_join"}
db: select * from book where id = 1
db: select person.status,person.env_id,person.position,person.locked,person.updated_at,person.created_at,person.first_name,person.locale_id,person.id from person inner join books_reader on (person.id = books_reader.reader_id) where books_reader.books_id = 1
error: error rendering /book/1: org.postgresql.util.PSQLException: ERROR: relation "books_reader" does not exist
  Position: 170
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2077)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1810)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:498)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:386)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
    at clojure.java.jdbc.internal$with_query_results_STAR_.invoke(internal.clj:328)
    at caribou.db$query.doInvoke(db.clj:41)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invoke(core.clj:602)
    at clojure.core$partial$fn__3794.doInvoke(core.clj:2341)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:600)
    at caribou.model$retrieve_links.invoke(model.clj:596)
    at caribou.model.LinkField.fieldaction: list-all => {:slug "books_person", :limit "1000"}
action: list-all => {:slug "person", :limit "1000"}
db: select * from books_person where 1=1 order by position asc limit 1000 offset 0
db: select * from person where 1=1 order by position asc limit 1000 offset 0
db: select count(id) from person
db: select count(id) from books_person
_from(model.clj:667)
    at caribou.model.LinkField.render(model.clj:671)
    at caribou.model$fields_render$fn__2338.invoke(model.clj:717)
    at clojure.core.protocols$fn__5558.invoke(protocols.clj:64)
    at clojure.core.protocols$fn__5543$G__5538__5552.invoke(protocols.clj:11)
    at clojure.core$reduce.invoke(core.clj:5995)
    at caribou.model$fields_render.invoke(model.clj:716)
    at caribou.model$model_render.invoke(model.clj:724)
    at caribou.api.core$render.invoke(core.clj:42)
    at caribou.api.core$item_detail.invoke(core.clj:215)
    at caribou.api.core$init$fn__211.invoke(core.clj:295)
    at compojure.core$if_route$fn__48.invoke(core.clj:39)
    at compojure.core$if_method$fn__41.invoke(core.clj:24)
    at compojure.core$routing$fn__63.invoke(core.clj:98)
    at clojure.core$some.invoke(core.clj:2388)
    at compojure.core$routing.doInvoke(core.clj:98)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invoke(core.clj:602)
    at compojure.core$routes$fn__67.invoke(core.clj:103)
    at sandbar.auth$with_security$fn__1314.invoke(auth.clj:235)
    at ring.middleware.keyword_params$wrap_keyword_params$fn__1417.invoke(keyword_params.clj:27)
    at ring.middleware.nested_params$wrap_nested_params$fn__1454.invoke(nested_params.clj:65)
    at ring.middleware.params$wrap_params$fn__1391.invoke(params.clj:55)
    at ring.middleware.multipart_params$wrap_multipart_params$fn__1480.invoke(multipart_params.clj:103)
    at ring.middleware.flash$wrap_flash$fn__985.invoke(flash.clj:14)
    at ring.middleware.session$wrap_session$fn__1235.invoke(session.clj:40)
    at ring.middleware.cookies$wrap_cookies$fn__1173.invoke(cookies.clj:160)
    at sandbar.stateful_session$wrap_stateful_session_STAR_$fn__1243.invoke(stateful_session.clj:65)
    at ring.middleware.flash$wrap_flash$fn__985.invoke(flash.clj:14)
    at ring.middleware.session$wrap_session$fn__1235.invoke(session.clj:40)
    at ring.middleware.cookies$wrap_cookies$fn__1173.invoke(cookies.clj:160)
    at caribou.db$wrap_db$fn__400$fn__401.invoke(db.clj:227)
    at clojure.java.jdbc.internal$with_connection_STAR_.invoke(internal.clj:156)
    at caribou.db$wrap_db$fn__400.invoke(db.clj:227)
    at sandbar.auth$with_secure_channel$fn__1309.invoke(auth.clj:216)
    at clojure.lang.Var.invoke(Var.java:401)
    at ring.middleware.stacktrace$wrap_stacktrace_log$fn__215.invoke(stacktrace.clj:15)
    at ring.middleware.stacktrace$wrap_stacktrace_web$fn__247.invoke(stacktrace.clj:79)
    at ring.middleware.reload$wrap_reload$fn__388.invoke(reload.clj:18)
    at ring.adapter.jetty$proxy_handler$fn__87.invoke(jetty.clj:16)
    at ring.adapter.jetty.proxy$org.mortbay.jetty.handler.AbstractHandler$0.handle(Unknown Source)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)