Azure / Azure/azure-functions-sql-extension

Sql trigger cannot deserialize types with properties stored as json

Open
#908 2 comments 0 reactions 0 assignees View on GitHub
bug trigger
Dominant language
C#
Stars
130
Forks
71
Avg merge
4d 8h
Merged PRs (30d)
4

Description

The SQL trigger fails when trying to deserialize types that have columns stored as Json that map to object types (for example an owned type that was stored as Json in EFCore). I tried adding a custom converter for handling this in the function startup but can't seem to override the default serialization behavior.

For now, I have two options for working around the issue. One method that worked was adding a class that specified the properties as strings, using that as the SqlChange<> type, then converting it to the target type in the function. I was also able to pass in JObject as the type for SqlChange<> and then use the custom converter inside of the JObject.ToObject method to convert.

https://github.com/Azure/azure-functions-sql-extension/blob/release/trigger/src/TriggerBinding/SqlTableChangeMonitor.cs#L705

Contributor guide

Open the contributing guide

Research direction

Start with SqlTableChangeMonitor.cs around line 705, where the SQL trigger deserializes SqlChange values. Reproduce the case involving JSON-backed object properties and compare it with the custom-converter and JObject workarounds described in the issue. Done means the trigger can deserialize the target object while allowing the function's custom converter behavior to take effect.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, sql
Domain
backend, cloud, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.