From b04a79e9480aa7ab92cdf58101dfe30b4aebf497 Mon Sep 17 00:00:00 2001 From: Luke Amdor Date: Tue, 9 Jun 2026 18:08:19 -0500 Subject: [PATCH] tests: accept AbstractDict for compatibility with JSON.jl v1 JSON.jl v1 parses JSON objects into JSON.Object{String,Any} rather than Dict{String,Any}. Several method signatures were restricted to Dict{String,Any}, so the OPA partial-compile results (which are JSON-parsed) no longer matched on current Julia, breaking the Config API and Compile API testsets. (The suite still passed on Julia 1.6, which resolves an older JSON.jl that returns Dict.) Widen the affected signatures to AbstractDict, which JSON.Object is a subtype of: the QuerySet AST-walk entry point in src/utils/ast.jl (production code, so consumers passing JSON.Object results now work), the standalone reference translator's translate(), and two Config API isa(..., Dict) assertions in the test suite. --- src/utils/ast.jl | 2 +- test/runtests.jl | 4 ++-- test/sql_translate.jl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/ast.jl b/src/utils/ast.jl index e8c346b..b4c2e57 100644 --- a/src/utils/ast.jl +++ b/src/utils/ast.jl @@ -142,7 +142,7 @@ function after(visitor::ASTVisitor, node) return pop!(visitor.result_stack) # either a QuerySet or nothing end -function _visit(visitor::ASTVisitor, ::Type{QuerySet}, node::Dict{String,Any}) +function _visit(visitor::ASTVisitor, ::Type{QuerySet}, node::AbstractDict) if haskey(node, "queries") && length(node["queries"]) > 0 data = node["queries"] N = length(data) diff --git a/test/runtests.jl b/test/runtests.jl index 97f2f0e..3d0bfbd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -91,11 +91,11 @@ function test_config_api(openapi_client) @test length(services) == 1 @test services[1]["name"] == "BundleServiceAPI" - @test haskey(result, "bundles") && isa(result["bundles"], Dict) + @test haskey(result, "bundles") && isa(result["bundles"], AbstractDict) bundles = result["bundles"] @test Set(keys(bundles)) == Set(["data", "policies"]) - @test haskey(result, "keys") && isa(result["keys"], Dict) + @test haskey(result, "keys") && isa(result["keys"], AbstractDict) bundle_keys = result["keys"] @test haskey(bundle_keys, "bundle_key") @test haskey(bundle_keys["bundle_key"], "algorithm") diff --git a/test/sql_translate.jl b/test/sql_translate.jl index 10395e7..bff08c7 100644 --- a/test/sql_translate.jl +++ b/test/sql_translate.jl @@ -267,7 +267,7 @@ function to_sql(queryset::QuerySet) end end -function translate(result::Dict{String, Any}) +function translate(result::AbstractDict) if haskey(result, "queries") && length(result["queries"]) > 0 return to_sql(from_data(QuerySet, result["queries"])) else