Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Odd behavior with JsonNode as parameter. #6578

Copy link
Copy link

Description

@PetSerAl
Issue body actions

JsonNode have no way to represent JSON null as object. Instead JsonNode represent JSON null as null reference: JsonNode.Parse("null") is null returns true. That cause some issues when passing such value as NpgsqlParameter.

When using non-generic NpgsqlParameter: new NpgsqlParameter { NpgsqlDbType = NpgsqlDbType.Jsonb, Value = JsonNode.Parse("null") } it cause exception: System.InvalidOperationException: Parameter '' cannot be null, DBNull.Value should be used instead. That is understandable as no type information associated with null reference.

With generic NpgsqlParameter: new NpgsqlParameter<JsonNode> { NpgsqlDbType = NpgsqlDbType.Jsonb, TypedValue = JsonNode.Parse("null") } it passes value as SQL NULL, but not as JSON null.

As I can see, there is no way to pass JSON null value by using JsonNode. There is no issue when JSON null is part of JSON array or JSON object. Only when JSON null is entire JSON document.

Not sure if current behavior could/should be changed from compatibility point of view, but it definitely should be documented.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.