Skip to content

Json for special key #1585

@wuyu8512

Description

@wuyu8512

Hello, I have some data like

{
   "318":{
      "cid":8,
      "xPath":"//*[@id=\"app\"]/div[1]/div[2]/div[1]/div[1]/div[2]/div[1]/p[411]"
   },
   "329":{
      "cid":7,
      "xPath":""
   }
}
var readPostion = await _context.UserData.Where(x => x.UserId == userId)
    .Select(x => x.ReadPosition[bid.ToString()])
    .FirstOrDefaultAsync();

ReadPosition is JObject, bid is int

They generated sql statements like this

SELECT JSON_EXTRACT(`u`.`read_position`, '$.318')
FROM `user_data` AS `u`
WHERE `u`.`user_id` = 2
LIMIT 1

and throw an error Invalid JSON path expression. The error is around character position 5.

The correct one should be like this

SELECT JSON_EXTRACT(`u`.`read_position`, '$."318"')
FROM `user_data` AS `u`
WHERE `u`.`user_id` = 2
LIMIT 1

Is this a bug, or am I missing something?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions