diff --git a/beanquery/compiler.py b/beanquery/compiler.py index d9761cc..390f5f6 100644 --- a/beanquery/compiler.py +++ b/beanquery/compiler.py @@ -525,7 +525,7 @@ def _unaryop(self, node: ast.UnaryOp): function = types.function_lookup(OPERATORS, type(node), [operand]) if function is None: raise CompilationError( - f'operator "{type(node).__name__.lower()}({operand.dtype.__name__})" not supported', node) + f'operator "{type(node).__name__.lower()}({types.name(operand.dtype)})" not supported', node) function = function(operand) # Constants folding. if isinstance(operand, EvalConstant): @@ -593,7 +593,7 @@ def _binaryop(self, node: ast.BinaryOp): raise CompilationError( f'operator "{type(node).__name__.lower()}(' - f'{left.dtype.__name__}, {right.dtype.__name__})" not supported', node) + f'{types.name(left.dtype)}, {types.name(right.dtype)})" not supported', node) @_compile.register def _constant(self, node: ast.Constant): diff --git a/beanquery/types.py b/beanquery/types.py index 753252f..baa9dac 100644 --- a/beanquery/types.py +++ b/beanquery/types.py @@ -90,4 +90,6 @@ def function_lookup(functions, name, operands): def name(datatype): + if datatype is NoneType: + return 'NULL' return getattr(datatype, 'name', datatype.__name__.lower())