@@ -178,8 +178,11 @@ def where(self, condition):
178
178
"""
179
179
self ._has_where = True
180
180
self ._where = condition
181
- expr = ExprParser (condition , not self ._doc_based )
182
- self ._where_expr = expr .expr ()
181
+ try :
182
+ expr = ExprParser (condition , not self ._doc_based )
183
+ self ._where_expr = expr .expr ()
184
+ except ValueError :
185
+ raise ProgrammingError ("Invalid condition" )
183
186
self ._binding_map = expr .placeholder_name_to_position
184
187
return self
185
188
@@ -463,7 +466,7 @@ def execute(self):
463
466
mysqlx.Result: Result object.
464
467
"""
465
468
if not self ._has_where :
466
- raise ProgrammingError ("No condition was found for modify. " )
469
+ raise ProgrammingError ("No condition was found for modify" )
467
470
return self ._connection .update (self )
468
471
469
472
@@ -667,7 +670,7 @@ def execute(self):
667
670
mysqlx.Result: Result object
668
671
"""
669
672
if not self ._has_where :
670
- raise ProgrammingError ("No condition was found for update. " )
673
+ raise ProgrammingError ("No condition was found for update" )
671
674
return self ._connection .update (self )
672
675
673
676
@@ -687,7 +690,7 @@ def execute(self):
687
690
mysqlx.Result: Result object.
688
691
"""
689
692
if not self ._has_where :
690
- raise ProgrammingError ("No condition was found for remove. " )
693
+ raise ProgrammingError ("No condition was found for remove" )
691
694
return self ._connection .delete (self )
692
695
693
696
@@ -711,7 +714,7 @@ def execute(self):
711
714
mysqlx.Result: Result object.
712
715
"""
713
716
if not self ._has_where :
714
- raise ProgrammingError ("No condition was found for delete. " )
717
+ raise ProgrammingError ("No condition was found for delete" )
715
718
return self ._connection .delete (self )
716
719
717
720
@@ -875,7 +878,7 @@ def defined_as(self, statement):
875
878
if not isinstance (statement , SelectStatement ) and \
876
879
not isinstance (statement , STRING_TYPES ):
877
880
raise ProgrammingError ("The statement must be an instance of "
878
- "SelectStatement or a SQL string. " )
881
+ "SelectStatement or a SQL string" )
879
882
self ._defined_as = copy .copy (statement ) # Prevent modifications
880
883
return self
881
884
0 commit comments