Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ protected override bool TrySerializeScalarToJson(
private SqlExpression JsonNull(RelationalTypeMapping jsonTypeMapping)
=> new SqlUnaryExpression(
ExpressionType.Convert,
_sqlExpressionFactory.Constant("null"),
_sqlExpressionFactory.Constant("null", _typeMappingSource.FindMapping(typeof(string))),
jsonTypeMapping.ClrType,
jsonTypeMapping);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override async Task Update_property_inside_associate()
@p='?'

UPDATE "RootEntity" AS r
SET "RequiredAssociate" = jsonb_set_lax(r."RequiredAssociate", '{String}', to_jsonb(@p))
SET "RequiredAssociate" = jsonb_set(r."RequiredAssociate", '{String}', to_jsonb(@p))
""");
}

Expand All @@ -60,7 +60,7 @@ public override async Task Update_property_inside_associate_with_special_chars()
AssertExecuteUpdateSql(
"""
UPDATE "RootEntity" AS r
SET "RequiredAssociate" = jsonb_set_lax(r."RequiredAssociate", '{String}', to_jsonb('{ Some other/JSON:like text though it [isn''t]: ממש ממש לאéèéè }'::text))
SET "RequiredAssociate" = jsonb_set(r."RequiredAssociate", '{String}', to_jsonb('{ Some other/JSON:like text though it [isn''t]: ממש ממש לאéèéè }'::text))
WHERE (r."RequiredAssociate" ->> 'String') = '{ this may/look:like JSON but it [isn''t]: ממש ממש לאéèéè }'
""");
}
Expand All @@ -74,7 +74,7 @@ public override async Task Update_property_inside_nested_associate()
@p='?'

UPDATE "RootEntity" AS r
SET "RequiredAssociate" = jsonb_set_lax(r."RequiredAssociate", '{RequiredNestedAssociate,String}', to_jsonb(@p))
SET "RequiredAssociate" = jsonb_set(r."RequiredAssociate", '{RequiredNestedAssociate,String}', to_jsonb(@p))
""");
}

Expand All @@ -87,7 +87,7 @@ public override async Task Update_property_on_projected_associate()
@p='?'

UPDATE "RootEntity" AS r
SET "RequiredAssociate" = jsonb_set_lax(r."RequiredAssociate", '{String}', to_jsonb(@p))
SET "RequiredAssociate" = jsonb_set(r."RequiredAssociate", '{String}', to_jsonb(@p))
""");
}

Expand Down Expand Up @@ -131,7 +131,7 @@ public override async Task Update_nested_associate_to_parameter()
@complex_type_p='?' (DbType = Object)

UPDATE "RootEntity" AS r
SET "RequiredAssociate" = jsonb_set_lax(r."RequiredAssociate", '{RequiredNestedAssociate}', @complex_type_p)
SET "RequiredAssociate" = jsonb_set(r."RequiredAssociate", '{RequiredNestedAssociate}', @complex_type_p)
""");
}

Expand Down Expand Up @@ -258,7 +258,7 @@ public override async Task Update_nested_collection_to_parameter()
@complex_type_p='?' (DbType = Object)

UPDATE "RootEntity" AS r
SET "RequiredAssociate" = jsonb_set_lax(r."RequiredAssociate", '{NestedCollection}', @complex_type_p)
SET "RequiredAssociate" = jsonb_set(r."RequiredAssociate", '{NestedCollection}', @complex_type_p)
""");
}

Expand All @@ -280,7 +280,7 @@ public override async Task Update_nested_collection_to_another_nested_collection
AssertExecuteUpdateSql(
"""
UPDATE "RootEntity" AS r
SET "RequiredAssociate" = jsonb_set_lax(r."RequiredAssociate", '{NestedCollection}', r."OptionalAssociate" -> 'NestedCollection')
SET "RequiredAssociate" = jsonb_set(r."RequiredAssociate", '{NestedCollection}', COALESCE(r."OptionalAssociate" -> 'NestedCollection', 'null'::jsonb))
WHERE (r."OptionalAssociate") IS NOT NULL
""");
}
Expand Down Expand Up @@ -323,7 +323,7 @@ public override async Task Update_primitive_collection_to_parameter()
@ints='?' (DbType = Object)

UPDATE "RootEntity" AS r
SET "RequiredAssociate" = jsonb_set_lax(r."RequiredAssociate", '{Ints}', @ints)
SET "RequiredAssociate" = jsonb_set(r."RequiredAssociate", '{Ints}', @ints)
""");
}

Expand All @@ -347,7 +347,7 @@ public override async Task Update_inside_primitive_collection()
@p='?' (DbType = Int32)

UPDATE "RootEntity" AS r
SET "RequiredAssociate" = jsonb_set_lax(r."RequiredAssociate", '{Ints,1}', to_jsonb(@p))
SET "RequiredAssociate" = jsonb_set(r."RequiredAssociate", '{Ints,1}', to_jsonb(@p))
WHERE jsonb_array_length(r."RequiredAssociate" -> 'Ints') >= 2
""");
}
Expand All @@ -366,7 +366,7 @@ public override async Task Update_multiple_properties_inside_same_associate()
@p1='?' (DbType = Int32)

UPDATE "RootEntity" AS r
SET "RequiredAssociate" = jsonb_set_lax(jsonb_set_lax(r."RequiredAssociate", '{String}', to_jsonb(@p)), '{Int}', to_jsonb(@p1))
SET "RequiredAssociate" = jsonb_set(jsonb_set(r."RequiredAssociate", '{String}', to_jsonb(@p)), '{Int}', to_jsonb(@p1))
""");
}

Expand All @@ -380,8 +380,8 @@ public override async Task Update_multiple_properties_inside_associates_and_on_e

UPDATE "RootEntity" AS r
SET "Name" = r."Name" || 'Modified',
"RequiredAssociate" = jsonb_set_lax(r."RequiredAssociate", '{String}', r."OptionalAssociate" -> 'String'),
"OptionalAssociate" = jsonb_set_lax(r."OptionalAssociate", '{RequiredNestedAssociate,String}', to_jsonb(@p))
"RequiredAssociate" = jsonb_set(r."RequiredAssociate", '{String}', COALESCE(r."OptionalAssociate" -> 'String', 'null'::jsonb)),
"OptionalAssociate" = jsonb_set(r."OptionalAssociate", '{RequiredNestedAssociate,String}', to_jsonb(@p))
WHERE (r."OptionalAssociate") IS NOT NULL
""");
}
Expand All @@ -395,8 +395,8 @@ public override async Task Update_multiple_projected_associates_via_anonymous_ty
@p='?'

UPDATE "RootEntity" AS r
SET "RequiredAssociate" = jsonb_set_lax(r."RequiredAssociate", '{String}', r."OptionalAssociate" -> 'String'),
"OptionalAssociate" = jsonb_set_lax(r."OptionalAssociate", '{String}', to_jsonb(@p))
SET "RequiredAssociate" = jsonb_set(r."RequiredAssociate", '{String}', COALESCE(r."OptionalAssociate" -> 'String', 'null'::jsonb)),
"OptionalAssociate" = jsonb_set(r."OptionalAssociate", '{String}', to_jsonb(@p))
WHERE (r."OptionalAssociate") IS NOT NULL
""");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override async Task ExecuteUpdate_within_json_to_parameter()
@Fixture_OtherValue='False'

UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
""");
}

Expand All @@ -69,7 +69,7 @@ public override async Task ExecuteUpdate_within_json_to_constant()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(FALSE::boolean))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(FALSE::boolean))
""");
}

Expand All @@ -91,7 +91,7 @@ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(j."OtherValue"))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(j."OtherValue"))
""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override async Task ExecuteUpdate_within_json_to_parameter()
@Fixture_OtherValue='0x04050607'

UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(encode(@Fixture_OtherValue, 'base64')))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(encode(@Fixture_OtherValue, 'base64')))
""");
}

Expand All @@ -69,7 +69,7 @@ public override async Task ExecuteUpdate_within_json_to_constant()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(encode(BYTEA E'\\x04050607', 'base64')))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(encode(BYTEA E'\\x04050607', 'base64')))
""");
}

Expand All @@ -80,7 +80,7 @@ public override async Task ExecuteUpdate_within_json_to_another_json_property()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(encode(decode(j."JsonContainer" ->> 'OtherValue', 'base64'), 'base64')))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', COALESCE(to_jsonb(encode(decode(j."JsonContainer" ->> 'OtherValue', 'base64'), 'base64')), 'null'::jsonb))
""");
}

Expand All @@ -91,7 +91,7 @@ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(encode(j."OtherValue", 'base64')))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', COALESCE(to_jsonb(encode(j."OtherValue", 'base64')), 'null'::jsonb))
""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override async Task ExecuteUpdate_within_json_to_parameter()
@Fixture_OtherValue='ae192c36-9004-49b2-b785-8be10d169627'

UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
""");
}

Expand All @@ -69,7 +69,7 @@ public override async Task ExecuteUpdate_within_json_to_constant()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb('ae192c36-9004-49b2-b785-8be10d169627'::uuid))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb('ae192c36-9004-49b2-b785-8be10d169627'::uuid))
""");
}

Expand All @@ -91,7 +91,7 @@ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(j."OtherValue"))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(j."OtherValue"))
""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override async Task ExecuteUpdate_within_json_to_parameter()
@Fixture_OtherValue='bar'

UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
""");
}

Expand All @@ -69,7 +69,7 @@ public override async Task ExecuteUpdate_within_json_to_constant()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb('bar'::text))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb('bar'::text))
""");
}

Expand All @@ -80,7 +80,7 @@ public override async Task ExecuteUpdate_within_json_to_another_json_property()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', j."JsonContainer" -> 'OtherValue')
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', COALESCE(j."JsonContainer" -> 'OtherValue', 'null'::jsonb))
""");
}

Expand All @@ -91,7 +91,7 @@ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(j."OtherValue"))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', COALESCE(to_jsonb(j."OtherValue"), 'null'::jsonb))
""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override async Task ExecuteUpdate_within_json_to_parameter()
@Fixture_OtherValue='192.168.1.2' (DbType = Object)

UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
""");
}

Expand All @@ -71,7 +71,7 @@ public override async Task ExecuteUpdate_within_json_to_constant()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(INET '192.168.1.2'::inet))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(INET '192.168.1.2'::inet))
""");
}

Expand All @@ -82,7 +82,7 @@ public override async Task ExecuteUpdate_within_json_to_another_json_property()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', j."JsonContainer" -> 'OtherValue')
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', COALESCE(j."JsonContainer" -> 'OtherValue', 'null'::jsonb))
""");
}

Expand All @@ -93,7 +93,7 @@ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(j."OtherValue"))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', COALESCE(to_jsonb(j."OtherValue"), 'null'::jsonb))
""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override async Task ExecuteUpdate_within_json_to_parameter()
@Fixture_OtherValue='001422012346' (DbType = Object)

UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
""");
}

Expand All @@ -71,7 +71,7 @@ public override async Task ExecuteUpdate_within_json_to_constant()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(MACADDR '001422012346'::macaddr))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(MACADDR '001422012346'::macaddr))
""");
}

Expand All @@ -82,7 +82,7 @@ public override async Task ExecuteUpdate_within_json_to_another_json_property()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', j."JsonContainer" -> 'OtherValue')
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', COALESCE(j."JsonContainer" -> 'OtherValue', 'null'::jsonb))
""");
}

Expand All @@ -93,7 +93,7 @@ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(j."OtherValue"))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', COALESCE(to_jsonb(j."OtherValue"), 'null'::jsonb))
""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override async Task ExecuteUpdate_within_json_to_parameter()
@Fixture_OtherValue='30'

UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
""");
}

Expand All @@ -69,7 +69,7 @@ public override async Task ExecuteUpdate_within_json_to_constant()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(30.0::numeric))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(30.0::numeric))
""");
}

Expand All @@ -91,7 +91,7 @@ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(j."OtherValue"))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(j."OtherValue"))
""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override async Task ExecuteUpdate_within_json_to_parameter()
@Fixture_OtherValue='30'

UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
""");
}

Expand All @@ -69,7 +69,7 @@ public override async Task ExecuteUpdate_within_json_to_constant()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(30.0::double precision))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(30.0::double precision))
""");
}

Expand All @@ -91,7 +91,7 @@ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(j."OtherValue"))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(j."OtherValue"))
""");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override async Task ExecuteUpdate_within_json_to_parameter()
@Fixture_OtherValue='30'

UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(@Fixture_OtherValue))
""");
}

Expand All @@ -69,7 +69,7 @@ public override async Task ExecuteUpdate_within_json_to_constant()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(30::real))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(30::real))
""");
}

Expand All @@ -91,7 +91,7 @@ public override async Task ExecuteUpdate_within_json_to_nonjson_column()
AssertSql(
"""
UPDATE "JsonTypeEntity" AS j
SET "JsonContainer" = jsonb_set_lax(j."JsonContainer", '{Value}', to_jsonb(j."OtherValue"))
SET "JsonContainer" = jsonb_set(j."JsonContainer", '{Value}', to_jsonb(j."OtherValue"))
""");
}

Expand Down
Loading
Loading