import { Serializable } from '../classes/Serializable'; export class RenameColumn implements Serializable { public column: string; public new_name: string; public constructor (column: string, new_name = null) { if (new_name === null) { const regex = /(?[a-z_]+) (?[a-z_]+)/iu; const res = regex.exec (column); if (res === null || typeof res.groups === 'undefined') throw new Error ('invalid string to deserialize'); this.column = res.groups.column; this.new_name = res.groups.new_name; return; } this.column = column; this.new_name = new_name as unknown as string; } public serialize (): string { return `${this.column} ${this.new_name}`; } }