File tree 4 files changed +43
-4
lines changed
tests/apps/migrations/auto
4 files changed +43
-4
lines changed Original file line number Diff line number Diff line change 15
15
"fastapi" : ["fastapi>=0.112.1" ],
16
16
"blacksheep" : ["blacksheep" ],
17
17
"litestar" : ["litestar" ],
18
- "esmerald" : ["esmerald" ],
18
+ "esmerald" : ["esmerald==3.3.0 " ],
19
19
"lilya" : ["lilya" ],
20
20
}
21
21
ROUTERS = list (ROUTER_DEPENDENCIES .keys ())
Original file line number Diff line number Diff line change @@ -40,10 +40,17 @@ def compare_dicts(
40
40
41
41
for key , value in dict_1 .items ():
42
42
dict_2_value = dict_2 .get (key , ...)
43
+
43
44
if (
44
- dict_2_value is not ...
45
- and dict_2_value != value
46
- or dict_2_value is ...
45
+ # If the value is `...` then it means no value was found.
46
+ (dict_2_value is ...)
47
+ # We have to compare the types, because if we just use equality
48
+ # then 1.0 == 1 is True.
49
+ # See this issue:
50
+ # https://github.com/piccolo-orm/piccolo/issues/1071
51
+ or (type (value ) is not type (dict_2_value ))
52
+ # Finally compare the actual values.
53
+ or (dict_2_value != value )
47
54
):
48
55
output [key ] = value
49
56
Original file line number Diff line number Diff line change @@ -888,6 +888,25 @@ def test_column_type_conversion_float_decimal(self):
888
888
]
889
889
)
890
890
891
+ def test_column_type_conversion_integer_float (self ):
892
+ """
893
+ Make sure conversion between ``Integer`` and ``Real`` works - related
894
+ to this bug:
895
+
896
+ https://github.com/piccolo-orm/piccolo/issues/1071
897
+
898
+ """
899
+ self ._test_migrations (
900
+ table_snapshots = [
901
+ [self .table (column )]
902
+ for column in [
903
+ Real (default = 1.0 ),
904
+ Integer (default = 1 ),
905
+ Real (default = 1.0 ),
906
+ ]
907
+ ]
908
+ )
909
+
891
910
def test_column_type_conversion_json (self ):
892
911
self ._test_migrations (
893
912
table_snapshots = [
Original file line number Diff line number Diff line change @@ -73,6 +73,19 @@ def test_enum_values(self):
73
73
response = compare_dicts (dict_1 , dict_2 )
74
74
self .assertEqual (response , {"a" : OnDelete .set_default })
75
75
76
+ def test_numeric_values (self ):
77
+ """
78
+ Make sure that if we have two numbers which are equal, but different
79
+ types, then they are identified as being different.
80
+
81
+ https://github.com/piccolo-orm/piccolo/issues/1071
82
+
83
+ """
84
+ dict_1 = {"a" : 1 }
85
+ dict_2 = {"a" : 1.0 }
86
+ response = compare_dicts (dict_1 , dict_2 )
87
+ self .assertEqual (response , {"a" : 1 })
88
+
76
89
77
90
class TestDiffableTable (TestCase ):
78
91
def test_subtract (self ):
You can’t perform that action at this time.
0 commit comments