JsonUtils
JsonUtils copied to clipboard
Converting to 'SQL Table' creates columns with 'IList<[varchar](50) NULL>' columns
Using the following JSON:
{ "command" : "testcommand", "data" : [ { "name" : "NameOfTheObject", "values" : { "Item1" : [ "Value1" ], "Item2" : [ "Value2" ], "Item3" : [ "Value3" ], "Item4" : [ "Value4" ], "Item5" : [ "Value5" ] } } ], "status" : "success" }
Incorrectly outputs the following SQL:
create table Values (
[Id] [int] IDENTITY(1,1) NOT NULL,
[Item1] IList<[varchar](50) NULL>,
[Item2] IList<[varchar](50) NULL>,
[Item3] IList<[varchar](50) NULL>,
[Item4] IList<[varchar](50) NULL>,
[Item5] IList<[varchar](50) NULL>,
CONSTRAINT [PK_Values] PRIMARY KEY CLUSTERED
(
[Id] asc
)
)
The correct output should be:
create table Values (
[Id] [int] IDENTITY(1,1) NO NULL,
[Item1] [varchar](50) NULL,
[Item2] [varchar](50) NULL,
[Item3] [varchar](50) NULL,
[Item4] [varchar](50) NULL,
[Item5] [varchar](50) NULL,
CONSTRAINT [PK_Values] PRIMARY KEY CLUSTERED
(
[Id] asc
)
)
The issue is the List is an array of json objects, and not a varcar. I made the sql output formatter simply as a helper, I don't think it can ever be perfectly right. If you have another thought, I'd be happy to accept a PR