Skip to content

Commit 2b3c7cf

Browse files
committed
Optimize logical calculation type judgment
1 parent 0f957a2 commit 2b3c7cf

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

syncanysql/calculaters/mysql_funcs/number_funcs.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,47 @@
99

1010
@typing_filter(float)
1111
def mysql_add(x, y):
12-
if x is None or y is None:
13-
return None
1412
if x.__class__ is int or x.__class__ is float:
1513
if y.__class__ is int or y.__class__ is float:
1614
return x + y
15+
if x is None or y is None:
16+
return None
1717
return ensure_number(x) + ensure_number(y)
1818

1919
@typing_filter(float)
2020
def mysql_sub(x, y):
21-
if x is None or y is None:
22-
return None
2321
if x.__class__ is int or x.__class__ is float:
2422
if y.__class__ is int or y.__class__ is float:
2523
return x - y
24+
if x is None or y is None:
25+
return None
2626
return ensure_number(x) - ensure_number(y)
2727

2828
@typing_filter(float)
2929
def mysql_mul(x, y):
30-
if x is None or y is None:
31-
return None
3230
if x.__class__ is int or x.__class__ is float:
3331
if y.__class__ is int or y.__class__ is float:
3432
return x * y
33+
if x is None or y is None:
34+
return None
3535
return ensure_number(x) * ensure_number(y)
3636

3737
@typing_filter(float)
3838
def mysql_div(x, y):
39-
if x is None or y is None:
40-
return None
4139
if x.__class__ is int or x.__class__ is float:
4240
if y.__class__ is int or y.__class__ is float:
4341
return x / y
42+
if x is None or y is None:
43+
return None
4444
return ensure_number(x) / ensure_number(y)
4545

4646
@typing_filter(float)
4747
def mysql_mod(x, y):
48-
if x is None or y is None:
49-
return None
5048
if x.__class__ is int or x.__class__ is float:
5149
if y.__class__ is int or y.__class__ is float:
5250
return x % y
51+
if x is None or y is None:
52+
return None
5353
return ensure_number(x) % ensure_number(y)
5454

5555
@typing_filter(int)

0 commit comments

Comments
 (0)