# -*- coding: utf-8 -*-
from ppms.migration.packet import *

OLD_VALUE = "SELECT DI024148 from DT500 WHERE DI024150= '{0}' AND DI024149 IN ('-', '{1}')"
NEW_VALUE = "SELECT DI024148 from DT500 WHERE DI024150= '{0}' AND (DI024149 IS NULL OR DI024149 IN ('{1}', '-'))"
class FixModuleVariantsQuery(ChangeDTPPacket):
    '''Update a query so public MVs can be worked with again'''
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 11121

    def fix(self, runner):
        record = self.get_record(343, ['-', '000269'], [40109])
        if self.change_value(record, 'source_text_clob', OLD_VALUE, NEW_VALUE):
            return self.success()    
        
        return self.fail()