Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field added after the requested version is exempt from versioning #58

Closed
CarlLooksUp opened this issue Jan 31, 2018 · 3 comments
Closed

Comments

@CarlLooksUp
Copy link

CarlLooksUp commented Jan 31, 2018

I start with some object

$ o = MyModel.create(a: 1, b: 2)

I add column c to MyModel in a migration

$ ap o
<MyModel: 0x00000> {
  :a => 1,
  :b => 2,
  :c => nil,
  :log_data => #<Logidze....>
}

I change the value of c

$ o.update(c: 3)

I request the initial version and expect to see the default value of c

$ o.at_version(1).c
3

Instead I see the most recent value of c.

Is this expectation reasonable? Is there a way to support this behavior if not by default then through configuration?

@palkan
Copy link
Owner

palkan commented Feb 1, 2018

Is this expectation reasonable?

Interesting case.

Your initial snapshot (version 1) doesn't contain c column value at all, that's why it hasn't been reset.
During the rollback we simply apply all the required diffs to the initial snapshot. Since none if the diffs contains c, the value stays the same.

expect to see the default value of c

Why default? Do you have not null constraint? In that case it make sense. Otherwise, it make sense to return nil.

Frankly speaking, I don't know whether Postgres invokes UPDATE triggers when you add a new not-null column with the default value. If that's true, than we should have a log entry.

To sum up, we do not handle adding/removing columns right now. I'll create a separate issue.

@palkan
Copy link
Owner

palkan commented Feb 1, 2018

@CarlLooksUp See #59

@palkan
Copy link
Owner

palkan commented Aug 29, 2018

Closed in favour of #59

@palkan palkan closed this as completed Aug 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants