diff --git a/dedupe/predicates.py b/dedupe/predicates.py
index 1934811..e796a6d 100644
--- a/dedupe/predicates.py
+++ b/dedupe/predicates.py
@@ -329,9 +329,14 @@ class CompoundPredicate(tuple):
     def __call__(self, record, **kwargs):
         predicate_keys = [predicate(record, **kwargs)
                           for predicate in self]
-        return [u':'.join(block_key)
-                for block_key
-                in itertools.product(*predicate_keys)]
+        return [
+            u':'.join(
+                # must escape : to avoid confusion with : join separator
+                b.replace(u':', u'\\:') for b in block_key
+            )
+            for block_key
+            in itertools.product(*predicate_keys)
+        ]
 
 
 def wholeFieldPredicate(field: Any) -> Tuple[str]:

CompoundPredicate should escape `:` to avoid wrong block_keys
I've found an issue on `CompoundPredicate` caused by the lack of escaping `:` chars inside fields.

This causes two problems. First, it can generate duplicate `block_key`s for the same `id`. Here's the example:

```
(SimplePredicate: (commonSetElementPredicate, name), SimplePredicate: (commonSetElementPredicate, address))
```

```
id  | name            | address    
---------------------------------------
1   | {'foo:', 'foo'} | {':bar', 'bar'}
```

```
id | block_key
---------------
1  | foo::bar:0
1  | foo::bar:0
```

That's probably not problematic for Dedupe 2, but that breaks [this line](https://github.com/dedupeio/dedupe-examples/blob/83dbf872674a5c3f6a209c367f46c7e6ef78e9a3/pgsql_big_dedupe_example/pgsql_big_dedupe_example.py#L246-L247) of the old `smaller_id`-based big Dedupe I still use.

Second, it can group together under the same `block_key` records that shouldn't be blocked together. See:

```
(SimplePredicate: (wholeFieldPredicate, name), SimplePredicate: (wholeFieldPredicate, address))
```

```
id  | name    | address    
---------------------------
1   | flavio: | one street
2   | flavio  | :one street
```

```
id | blocking_key
-------------------------
1  | flavio::one street:0
2  | flavio::one street:0
```

The solution is to escape `:` right before performing the `join` at this line:

https://github.com/dedupeio/dedupe/blob/5092f2598f1f2bcb4f3b1f0ec85f88b95ce7454b/dedupe/predicates.py#L332

Something like `u':'.join(block_key.replace(u':', u'\\:'))` would work, because the examples above would become this:

```
id | block_key
---------------
1  | foo\::bar:0
1  | foo:\:bar:0
```

```
id | blocking_key
-------------------------
1  | flavio\::one street:0
2  | flavio:\:one street:0
```

I'll open a PR for this.
diff --git a/tests/test_predicates.py b/tests/test_predicates.py
index deca290..714ac31 100644
--- a/tests/test_predicates.py
+++ b/tests/test_predicates.py
@@ -80,5 +80,47 @@ class TestNumericPredicates(unittest.TestCase):
         assert predicates.roundTo1(-22315) == (u'-20000',)
 
 
+class TestCompoundPredicate(unittest.TestCase):
+    def test_escapes_colon(self):
+        '''
+        Regression test for issue #836
+        '''
+        predicate_1 = predicates.SimplePredicate(
+            predicates.commonSetElementPredicate, 'col_1')
+        predicate_2 = predicates.SimplePredicate(
+            predicates.commonSetElementPredicate, 'col_2')
+        record = {
+            'col_1': ['foo:', 'foo'],
+            'col_2': [':bar', 'bar']
+        }
+
+        block_val = predicates.CompoundPredicate([
+            predicate_1,
+            predicate_2
+        ])(record)
+        assert len(set(block_val)) == 4
+        assert block_val == ['foo\\::\\:bar', 'foo\\::bar', 'foo:\\:bar', 'foo:bar']
+
+    def test_escapes_escaped_colon(self):
+        '''
+        Regression test for issue #836
+        '''
+        predicate_1 = predicates.SimplePredicate(
+            predicates.commonSetElementPredicate, 'col_1')
+        predicate_2 = predicates.SimplePredicate(
+            predicates.commonSetElementPredicate, 'col_2')
+        record = {
+            'col_1': ['foo\\:', 'foo'],
+            'col_2': ['\\:bar', 'bar']
+        }
+
+        block_val = predicates.CompoundPredicate([
+            predicate_1,
+            predicate_2
+        ])(record)
+        assert len(set(block_val)) == 4
+        assert block_val == ['foo\\\\::\\\\:bar', 'foo\\\\::bar', 'foo:\\\\:bar', 'foo:bar']
+
+
 if __name__ == '__main__':
     unittest.main()

pip install -e .
parse_log_pytest
requirements.txt
pytest pytest-cov mock mypy flake8
apt-get update apt-get install -y gcc
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
affinegap==1.12
BTrees==5.2
categorical-distance==1.9
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
coverage==7.2.7
datetime-distance==0.1.3
-e git+https://github.com/dedupeio/dedupe.git@5092f2598f1f2bcb4f3b1f0ec85f88b95ce7454b#egg=dedupe
dedupe-hcluster==0.3.9
dedupe-variable-datetime==0.1.5
DoubleMetaphone==1.1
exceptiongroup==1.2.2
fastcluster==1.2.6
flake8==5.0.4
future==1.0.0
haversine==2.9.0
highered==0.2.1
importlib-metadata==4.2.0
iniconfig==2.0.0
Levenshtein-search==1.4.6
mccabe==0.7.0
mock==5.2.0
mypy==1.4.1
mypy-extensions==1.0.0
numpy==1.21.6
packaging==24.0
persistent==5.2
pluggy==1.2.0
pycodestyle==2.9.1
pycparser==2.21
pyflakes==2.5.0
pyhacrf-datamade==0.2.8
PyLBFGS==0.2.0.16
pytest==7.4.4
pytest-cov==4.1.0
python-dateutil==2.9.0.post0
rlr==2.4.6
simplecosine==1.2
six==1.17.0
tomli==2.0.1
typed-ast==1.5.5
typing_extensions==4.7.1
zipp==3.15.0
zope.index==6.1
zope.interface==6.4.post2

name: dedupe
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - affinegap==1.12
      - btrees==5.2
      - categorical-distance==1.9
      - cffi==1.15.1
      - coverage==7.2.7
      - datetime-distance==0.1.3
      - dedupe==2.0.3
      - dedupe-hcluster==0.3.9
      - dedupe-variable-datetime==0.1.5
      - doublemetaphone==1.1
      - exceptiongroup==1.2.2
      - fastcluster==1.2.6
      - flake8==5.0.4
      - future==1.0.0
      - haversine==2.9.0
      - highered==0.2.1
      - importlib-metadata==4.2.0
      - iniconfig==2.0.0
      - levenshtein-search==1.4.6
      - mccabe==0.7.0
      - mock==5.2.0
      - mypy==1.4.1
      - mypy-extensions==1.0.0
      - numpy==1.21.6
      - packaging==24.0
      - persistent==5.2
      - pluggy==1.2.0
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pyflakes==2.5.0
      - pyhacrf-datamade==0.2.8
      - pylbfgs==0.2.0.16
      - pytest==7.4.4
      - pytest-cov==4.1.0
      - python-dateutil==2.9.0.post0
      - rlr==2.4.6
      - simplecosine==1.2
      - six==1.17.0
      - tomli==2.0.1
      - typed-ast==1.5.5
      - typing-extensions==4.7.1
      - zipp==3.15.0
      - zope-index==6.1
      - zope-interface==6.4.post2
prefix: /opt/conda/envs/dedupe

tests/test_predicates.py::TestCompoundPredicate::test_escapes_colon tests/test_predicates.py::TestCompoundPredicate::test_escapes_escaped_colon
tests/test_predicates.py::TestPuncStrip::test_set tests/test_predicates.py::TestPuncStrip::test_sevenchar tests/test_predicates.py::TestMetaphone::test_metaphone_token tests/test_predicates.py::TestWholeSet::test_full_set tests/test_predicates.py::TestSetElement::test_empty_set tests/test_predicates.py::TestSetElement::test_first_last tests/test_predicates.py::TestSetElement::test_long_set tests/test_predicates.py::TestSetElement::test_magnitude tests/test_predicates.py::TestLatLongGrid::test_precise_latlong tests/test_predicates.py::TestNumericPredicates::test_order_of_magnitude tests/test_predicates.py::TestNumericPredicates::test_round_to_1
dedupe/predicates.py
dedupe/predicates.py