def __init__(self, field, pattern):
        super().__init__(field, pattern)

        # Use a buffer/memoryview representation of the pattern for SQLite
        # matching. This instructs SQLite to treat the blob as binary
        # rather than encoded Unicode.
        if isinstance(self.pattern, (str, bytes)):
            if isinstance(self.pattern, str):
                self.pattern = self.pattern.encode('utf-8')
            self.buf_pattern = memoryview(self.pattern)
        elif isinstance(self.pattern, memoryview):
            self.buf_pattern = self.pattern
            self.pattern = bytes(self.pattern)