# Buggy code
def __call__(self, element, compiler, **kw):
    # TODO: yes, this could also switch off of DBAPI in use.
    fn = self.specs.get(compiler.dialect.name, None)
    if not fn:
        try:
            fn = self.specs["default"]
        except KeyError as ke:
            util.raise_(
                exc.CompileError(
                    "%s construct has no default compilation handler." % type(element)
                ),
                replace_context=ke,
            )

    # if compilation includes add_to_result_map, collect add_to_result_map
    # arguments from the user-defined callable, which are probably none
    # because this is not public API.  if it wasn't called, then call it
    # ourselves.
    arm = kw.get("add_to_result_map", None)
    if arm:
        arm_collection = []
        kw["add_to_result_map"] = lambda *args: arm_collection.append(args)

    expr = fn(element, compiler, **kw)

    if arm:
        if not arm_collection:
            arm_collection.append((None, None, (element,), sqltypes.NULLTYPE))
        for tup in arm_collection:
            arm(*tup)
    return expr


# Traceback (AttributeError)
Traceback (most recent call last):
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/visitors.py", line 89, in _compiler_dispatch
meth = getter(visitor)
AttributeError: 'StrSQLCompiler' object has no attribute 'visit_column_element'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/ext/compiler.py", line 425, in _wrap_existing_dispatch
return existing_dispatch(element, compiler, **kw)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/visitors.py", line 93, in _compiler_dispatch
replace_context=err,
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
raise exception
sqlalchemy.exc.UnsupportedCompilationError: Compiler <sqlalchemy.sql.compiler.StrSQLCompiler object at 0x7f01d84cf8d0> can't render element of type <class 'sqlalchemy.sql.elements.ColumnElement'> (Background on this error at: http://sqlalche.me/e/13/l7de)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "repro.py", line 89, in <module>
main()
File "repro.py", line 85, in main
print(result)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3538, in __str__
context = self._compile_context()
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 4114, in _compile_context
context.statement = self._compound_eager_statement(context)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 4180, in _compound_eager_statement
from_clause, eager_join, eager_join.stop_on
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/util.py", line 621, in splice_joins
right.onclause = adapter.traverse(right.onclause)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/visitors.py", line 240, in traverse
return replacement_traverse(obj, self.__traverse_options__, replace)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/visitors.py", line 484, in replacement_traverse
obj = clone(obj, **opts)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/visitors.py", line 473, in clone
newelem = replace(elem)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/visitors.py", line 236, in replace
e = v.replace(elem)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/util.py", line 848, in replace
return self._corresponding_column(col, True)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/util.py", line 821, in _corresponding_column
col, require_embedded=require_embedded
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/selectable.py", line 560, in corresponding_column
if self.c.contains_column(column):
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 893, in __get__
obj.__dict__[self.__name__] = result = self.fget(obj)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/selectable.py", line 647, in columns
self._populate_column_collection()
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/selectable.py", line 1392, in _populate_column_collection
for col in self.element.columns._all_columns:
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 893, in __get__
obj.__dict__[self.__name__] = result = self.fget(obj)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/selectable.py", line 647, in columns
self._populate_column_collection()
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/selectable.py", line 3903, in _populate_column_collection
c._make_proxy(self, key=key, name=name, name_is_truncatable=True)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 844, in _make_proxy
key = str(self)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 491, in __str__
return str(self.compile())
File "<string>", line 1, in <lambda>
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 481, in compile
return self._compiler(dialect, bind=bind, **kw)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 487, in _compiler
return dialect.statement_compiler(dialect, self, **kw)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/compiler.py", line 592, in __init__
Compiled.__init__(self, dialect, statement, **kwargs)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/compiler.py", line 322, in __init__
self.string = self.process(self.statement, **compile_kwargs)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/sql/compiler.py", line 352, in process
return obj._compiler_dispatch(self, **kwargs)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/ext/compiler.py", line 441, in <lambda>
lambda *arg, **kw: existing(*arg, **kw),
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/ext/compiler.py", line 486, in __call__
return fn(element, compiler, **kw)
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/ext/compiler.py", line 432, in _wrap_existing_dispatch
from_=uce,
File "/root/git/feed_test_results/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
raise exception
sqlalchemy.exc.CompileError: <class '__main__.combine_date_time'> construct has no default compilation handler.

# Fixed code
def __call__(self, element, compiler, **kw):
    # TODO: yes, this could also switch off of DBAPI in use.
    fn = self.specs.get(compiler.dialect.name, None)
    if not fn:
        try:
            fn = self.specs["default"]
        except KeyError as ke:
            util.raise_(
                exc.UnsupportedCompilationError(
                    compiler,
                    type(element),
                    message="%s construct has no default "
                    "compilation handler." % type(element),
                ),
                replace_context=ke,
            )

    # if compilation includes add_to_result_map, collect add_to_result_map
    # arguments from the user-defined callable, which are probably none
    # because this is not public API.  if it wasn't called, then call it
    # ourselves.
    arm = kw.get("add_to_result_map", None)
    if arm:
        arm_collection = []
        kw["add_to_result_map"] = lambda *args: arm_collection.append(args)

    expr = fn(element, compiler, **kw)

    if arm:
        if not arm_collection:
            arm_collection.append((None, None, (element,), sqltypes.NULLTYPE))
        for tup in arm_collection:
            arm(*tup)
    return expr