这是维斯塔版本中的错误还是我做错了什么

发布于 2024-08-09 14:00:14 字数 2178 浏览 12 评论 0原文

我想我可能发现了 Vestal 版本中的一个错误 (http://github.com/laserlemon/vestal_versions) - 看起来 revert_to 的行为取决于我过去对同一对象所做的恢复。这是一个示例:

>> a = Annotation.find(1384)
=> #<Annotation id: 1384, body: "Just hanging out -- \"playing possum\" -- at the stor...", last_updated_by_id: 3, created_by_id: 3, song_id: 30, deleted_at: nil, created_at: "2009-09-06 01:56:55", updated_at: "2009-10-27 22:02:35", referent: "in the spot playing possum\nDebating my destination,...", vote_score: 0>
>> a.revert_to(9)
=> 9
>> a.body
=> #<RDiscount:0x21cf7bc @filter_styles=true, @smart=true, @fold_lines=nil, @filter_html=nil, @text="Just hanging out -- \"playing possum\" -- at the store, lacing up the new Nikes, trying to decide where to go for dinner">


>> a = Annotation.find(1384)
=> #<Annotation id: 1384, body: "Just hanging out -- \"playing possum\" -- at the stor...", last_updated_by_id: 3, created_by_id: 3, song_id: 30, deleted_at: nil, created_at: "2009-09-06 01:56:55", updated_at: "2009-10-27 22:02:35", referent: "in the spot playing possum\nDebating my destination,...", vote_score: 0>
>> a.revert_to(8)
=> 8
>> a.body
=> #<RDiscount:0x21b5a10 @filter_styles=true, @smart=true, @fold_lines=nil, @filter_html=nil, @text="I.e. just hanging out -- \"playing possum\" -- in the living room, lacing up the new Nikes, trying to decide where to go for dinner">
>> a.revert_to(:last)
=> 11
>> a.revert_to(9)
=> 9
>> a.body
=> #<RDiscount:0x21b5a10 @filter_styles=true, @smart=true, @fold_lines=nil, @filter_html=nil, @text="I.e. just hanging out -- \"playing possum\" -- in the living room, lacing up the new Nikes, trying to decide where to go for dinner">

即,如果我从新加载的注释中 revert_to(9) ,则正文字段包含一个 RDiscount 对象,其文本以“Justhangout -- \”playing possum\” 开头 - 在store”(这是版本 9 的主体)

但是,如果我从新加载的注释恢复到 revert_to(8),请检查注释的主体 revert_to(:last)revert_to(9),版本 9 中的注释主体将是错误的(它将与版本 8 中的注释主体匹配)

有什么想法吗?

I think I might have discovered a bug in Vestal Versions (http://github.com/laserlemon/vestal_versions) -- it seems like revert_to's behavior depends on the reverts I've done in the past with the same object. Here's an example:

>> a = Annotation.find(1384)
=> #<Annotation id: 1384, body: "Just hanging out -- \"playing possum\" -- at the stor...", last_updated_by_id: 3, created_by_id: 3, song_id: 30, deleted_at: nil, created_at: "2009-09-06 01:56:55", updated_at: "2009-10-27 22:02:35", referent: "in the spot playing possum\nDebating my destination,...", vote_score: 0>
>> a.revert_to(9)
=> 9
>> a.body
=> #<RDiscount:0x21cf7bc @filter_styles=true, @smart=true, @fold_lines=nil, @filter_html=nil, @text="Just hanging out -- \"playing possum\" -- at the store, lacing up the new Nikes, trying to decide where to go for dinner">


>> a = Annotation.find(1384)
=> #<Annotation id: 1384, body: "Just hanging out -- \"playing possum\" -- at the stor...", last_updated_by_id: 3, created_by_id: 3, song_id: 30, deleted_at: nil, created_at: "2009-09-06 01:56:55", updated_at: "2009-10-27 22:02:35", referent: "in the spot playing possum\nDebating my destination,...", vote_score: 0>
>> a.revert_to(8)
=> 8
>> a.body
=> #<RDiscount:0x21b5a10 @filter_styles=true, @smart=true, @fold_lines=nil, @filter_html=nil, @text="I.e. just hanging out -- \"playing possum\" -- in the living room, lacing up the new Nikes, trying to decide where to go for dinner">
>> a.revert_to(:last)
=> 11
>> a.revert_to(9)
=> 9
>> a.body
=> #<RDiscount:0x21b5a10 @filter_styles=true, @smart=true, @fold_lines=nil, @filter_html=nil, @text="I.e. just hanging out -- \"playing possum\" -- in the living room, lacing up the new Nikes, trying to decide where to go for dinner">

I.e., if I revert_to(9) from a freshly loaded annotation the body field contains an RDiscount object whose text starts "Just hanging out -- \"playing possum\" -- at the store" (which is what the body was as of version 9)

However, if I revert to revert_to(8) from a freshly loaded annotation, check the annotation's body, revert_to(:last), and revert_to(9), the annotation's body while in version 9 will be wrong (it will match the annotation's body from version 8)

Any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云朵有点甜 2024-08-16 14:00:14

这不是lvestal_versions中的错误,而是rails在版本更改后没有重新加载您的关联。
假设您的 Annotation 保存了 RDiscount 的 id,会发生以下情况:

  1. 您使用 RDiscount 获取 Annotation“a” > x 的 ID。
  2. 您将“a”恢复为以前的版本,RDiscount id 更改为 y。
  3. 你调用a.body,导致rails加载id为y的RDiscount对象。
  4. 您将“a”恢复为 :lastRDiscount id 再次更改为 x。
  5. 您再次调用a.body,但rails已经加载了RDiscount对象,并将返回该对象。

This is not a bug in vestal_versions, it's rails not reloading your association after a version change.
Assuming your Annotation holds the id to your RDiscount the following happens:

  1. you fetch an Annotation "a" with an RDiscount id of x.
  2. you revert "a" to a previous version, the RDiscount id changes to y.
  3. you call a.body, causing rails to load the RDiscount object with the id y.
  4. you revert "a" to :last, the RDiscount id changes to x again.
  5. you call a.body again, but rails has already loaded the RDiscount object and will return this object instead.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文