Babelfish for PostgreSQL provides the capability for PostgreSQL to work with applications written for Microsoft SQL Server. Babelfish understands the SQL Server wire-protocol and T-SQL, the Microsoft SQL Server query and procedural language, so you don’t have to switch database drivers or rewrite all of your application queries.
1> SELECT * FROM OPENJSON('{}') WITH(field int 'strict$.field')
2> go
Msg 33557097, Level 16, State 1, Server BABELFISH, Line 1
JSON object does not contain key "field"
1> DECLARE @json NVarChar(max)=N'{"someKey" : "someValue"}';
2> SELECT * from OPENJSON(@json,'$.somePathWhichDoesNotExists') WITH (id VARCHAR(100) '$')
3> go
id
----------------------------------------------------------------------------------------------------
NULL
1> DECLARE @json_p9 NVARCHAR(4000) = N'{"to":{"sub-object":["en-GB", "en-UK","de-AT","es-AR","sr-Cyrl"]}}';
2> SELECT [key], value FROM OPENJSON(@json_p9,'strict $.path.to."sub-object"')
3> go
Msg 33557097, Level 16, State 1, Server BABELFISH, Line 2
JSON object does not contain key "path"
1> DECLARE @json_p10 NVARCHAR(4000) = N'{"to":{"sub-object":["en-GB", "en-UK","de-AT","es-AR","sr-Cyrl"]}}';
2> SELECT [key], value FROM OPENJSON(@json_p10,'$.path.to."sub-object"')
3> go
key value
---------------------------------------------------------------------------------------------------------------------------
1> DECLARE @json_p8 NVARCHAR(4000) = N'{"path": {"to":{"sub-object":["en-GB", "en-UK","de-AT","es-AR","sr-Cyrl"]}}}';
2> SELECT [key], value FROM OPENJSON(@json_p8,'strict$.path.to."sub-object"')
3> go
nvarchar#!#nvarchar
0#!#en-GB
1#!#en-UK
2#!#de-AT
3#!#es-AR
4#!#sr-Cyrl
Check List
[ ] Commits are signed per the DCO using --signoff
By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.
Description
This commit adds test files for the engine fix of the crash in
tsql_openjson_with_get_subjsonb
.Engine PR: https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish/pull/400
Issues Resolved
BABEL-3820
Test Scenarios Covered
Check List
By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.