Class RR::LoggedChange
In: lib/rubyrep/logged_change.rb
Parent: Object

Describes a single logged record change.

Note: The change loading functionality depends on the current database session being executed in an open database transaction. Also at the end of change processing the transaction must be committed.

Methods

Constants

TYPE_CHANGES = { 'NI' => 'I', 'NU' => 'U', 'ND' => 'D', 'II' => 'I', # [1] 'IU' => 'I', 'ID' => 'N', 'UI' => 'U', # [1] 'UU' => 'U', 'UD' => 'D', 'DI' => 'U', 'DU' => 'U', # [1] 'DD' => 'D', # [1] }   A hash describing how the change state morph based on newly found change records.
  • key: String consisting of 2 letters
    • first letter: describes current type change (nothing, insert, update, delete)
    • second letter: the new change type as read of the change log table
  • value: The resulting change type.

[1]: such cases shouldn‘t happen. but just in case, choose the most sensible solution.

SHORT_TYPES = { 'I' => :insert, 'U' => :update, 'D' => :delete, 'N' => :no_change   A hash translating the short 1-letter types to the according symbols
LONG_TYPES = SHORT_TYPES.invert   A hash translating the symbold types to according 1 letter types

Attributes

first_changed_at  [RW]  When the first change to the record happened
key  [RW]  A column_name => value hash identifying the changed record
last_changed_at  [RW]  When the last change to the record happened
loader  [RW]  The current LoggedChangeLoader
new_key  [RW]  Only used for updates: a column_name => value hash of the original primary key of the updated record
table  [RW]  The name of the changed table
type  [RW]  Type of the change. Either :insert, :update or :delete.

Public Class methods

Creates a new LoggedChange instance.

Public Instance methods

The current database (either +:left+ or +:right+)

Returns the configured key separator

Returns a column_name => value hash based on the provided raw_key string (which is a string in the format as read directly from the change log table).

Loads the change as per table and key. Works if the LoggedChange instance is totally new or was already loaded before.

Loads the oldest available change

Loads the change with the specified key for the named table.

  • table: name of the table
  • key: a column_name => value hash for all primary key columns of the table

The current Session

Prevents session from going into YAML output

[Validate]