ARTICLE AD BOX
I am using GORM with SQL Server and evaluating SQL Server 2025’s native JSON type and JSON indexing features. During testing, I found that some SQL Server JSON operations seem difficult or impossible to express through GORM’s query builder.
The SQL features I need to use include:
1. OPENJSON + CROSS APPLY (table-valued JSON expansion)
Example:
SELECT c.Id, v.cve, v.score FROM Snapshots c CROSS APPLY OPENJSON(c.Data, '$.vulnerabilities') WITH ( cve nvarchar(50) '$.cve', score float '$.score' ) AS v;I am not able to express this through GORM.
GORM does not appear to support APPLY or table-valued functions in the FROM clause.
2. JSON_VALUE / JSON_QUERY inside GROUP BY
Example:
SELECT JSON_VALUE(Data, '$.severity') as Sev, COUNT(*) FROM Snapshots GROUP BY JSON_VALUE(Data, '$.severity');GORM’s .Group() method seems to accept only literal column names, not expressions.
3. Computed Columns for JSON indexing
Example:
ALTER TABLE Snapshots ADD Severity AS JSON_VALUE(Data, '$.severity') PERSISTED;GORM migrations do not appear to support computed columns or JSON-based indexes.
4. Nested JSON graph traversal via multiple OPENJSON + CROSS APPLY
This requires multiple APPLY chains, which I do not see a way to express in GORM.
Questions:
Does GORM currently support any of the above SQL Server JSON features?
Is there a planned roadmap or ongoing work to add support for SQL Server 2025 JSON functions?
Is raw SQL (manual DAL layer) the recommended approach for these cases when using GORM with SQL Server?
