Class: Wal::Replicator::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/wal/replicator.rb

Instance Method Summary collapse

Instance Method Details

#decode_row(values) ⇒ Object



198
199
200
201
202
203
# File 'lib/wal/replicator.rb', line 198

def decode_row(values)
  values
    .zip(columns)
    .map { |tuple, col| [col.name, col.decode(tuple.data)] }
    .to_h
end

#full_table_nameObject



171
172
173
174
175
176
177
178
# File 'lib/wal/replicator.rb', line 171

def full_table_name
  case schema
  in "public"
    name
  else
    "#{schema}.#{name}"
  end
end

#primary_key(decoded_row) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/wal/replicator.rb', line 180

def primary_key(decoded_row)
  case primary_key_colums
  in [key]
    case decoded_row[key]
    in Integer => id
      id
    in String => id
      id
    else
      # Only supporting string and integer primary keys for now
      nil
    end
  else
    # Not supporting coumpound primary keys
    nil
  end
end