diff --git a/examples/python/sqlc.json b/examples/python/sqlc.json index 04ebe36b0f..88bafff072 100644 --- a/examples/python/sqlc.json +++ b/examples/python/sqlc.json @@ -5,7 +5,7 @@ "name": "py", "wasm": { "url": "https://github.com/tabbed/sqlc-gen-python/releases/download/v0.16.0-alpha/sqlc-gen-python.wasm", - "sha256": "428476c7408fd4c032da4ec74e8a7344f4fa75e0f98a5a3302f238283b9b95f2" + "sha256": "4fb54ee7d25b4d909b59a8271ebee60ad76ff17b10d61632a5ca5651e4bfe438" } } ], diff --git a/internal/endtoend/testdata/emit_pydantic_models/sqlc.json b/internal/endtoend/testdata/emit_pydantic_models/sqlc.json index db22ff525b..f5e9335ab7 100644 --- a/internal/endtoend/testdata/emit_pydantic_models/sqlc.json +++ b/internal/endtoend/testdata/emit_pydantic_models/sqlc.json @@ -1,19 +1,31 @@ { "version": "2", + "plugins": [ + { + "name": "py", + "wasm": { + "url": "https://github.com/tabbed/sqlc-gen-python/releases/download/v0.16.0-alpha/sqlc-gen-python.wasm", + "sha256": "4fb54ee7d25b4d909b59a8271ebee60ad76ff17b10d61632a5ca5651e4bfe438" + } + } + ], "sql": [ { "schema": "postgresql/schema.sql", "queries": "postgresql/query.sql", "engine": "postgresql", - "gen": { - "python": { + "codegen": [ + { + "plugin": "py", "out": "postgresql", - "package": "postgresql", - "emit_sync_querier": true, - "emit_async_querier": true, - "emit_pydantic_models": true + "options": { + "package": "postgresql", + "emit_sync_querier": true, + "emit_async_querier": true, + "emit_pydantic_models": true + } } - } + ] } ] } diff --git a/internal/endtoend/testdata/exec_result/python_postgresql/sqlc.json b/internal/endtoend/testdata/exec_result/python_postgresql/sqlc.json index ab1d93b949..606b57235b 100644 --- a/internal/endtoend/testdata/exec_result/python_postgresql/sqlc.json +++ b/internal/endtoend/testdata/exec_result/python_postgresql/sqlc.json @@ -1,18 +1,30 @@ { "version": "2", + "plugins": [ + { + "name": "py", + "wasm": { + "url": "https://github.com/tabbed/sqlc-gen-python/releases/download/v0.16.0-alpha/sqlc-gen-python.wasm", + "sha256": "4fb54ee7d25b4d909b59a8271ebee60ad76ff17b10d61632a5ca5651e4bfe438" + } + } + ], "sql": [ { "schema": "query.sql", "queries": "query.sql", "engine": "postgresql", - "gen": { - "python": { + "codegen": [ + { + "plugin": "py", "out": "python", - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true + "options": { + "package": "querytest", + "emit_sync_querier": true, + "emit_async_querier": true + } } - } + ] } ] } diff --git a/internal/endtoend/testdata/exec_rows/python_postgresql/sqlc.json b/internal/endtoend/testdata/exec_rows/python_postgresql/sqlc.json index ab1d93b949..606b57235b 100644 --- a/internal/endtoend/testdata/exec_rows/python_postgresql/sqlc.json +++ b/internal/endtoend/testdata/exec_rows/python_postgresql/sqlc.json @@ -1,18 +1,30 @@ { "version": "2", + "plugins": [ + { + "name": "py", + "wasm": { + "url": "https://github.com/tabbed/sqlc-gen-python/releases/download/v0.16.0-alpha/sqlc-gen-python.wasm", + "sha256": "4fb54ee7d25b4d909b59a8271ebee60ad76ff17b10d61632a5ca5651e4bfe438" + } + } + ], "sql": [ { "schema": "query.sql", "queries": "query.sql", "engine": "postgresql", - "gen": { - "python": { + "codegen": [ + { + "plugin": "py", "out": "python", - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true + "options": { + "package": "querytest", + "emit_sync_querier": true, + "emit_async_querier": true + } } - } + ] } ] } diff --git a/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/sqlc.json b/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/sqlc.json index f039809e26..f2156bb08f 100644 --- a/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/sqlc.json +++ b/internal/endtoend/testdata/inflection_exclude_table_names/python_postgresql/sqlc.json @@ -1,22 +1,34 @@ { "version": "2", + "plugins": [ + { + "name": "py", + "wasm": { + "url": "https://github.com/tabbed/sqlc-gen-python/releases/download/v0.16.0-alpha/sqlc-gen-python.wasm", + "sha256": "4fb54ee7d25b4d909b59a8271ebee60ad76ff17b10d61632a5ca5651e4bfe438" + } + } + ], "sql": [ { "schema": "query.sql", "queries": "query.sql", "engine": "postgresql", - "gen": { - "python": { + "codegen": [ + { + "plugin": "py", "out": "python", - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true, - "inflection_exclude_table_names": [ - "my_data", - "exclusions" - ] - } - } + "options": { + "package": "querytest", + "emit_sync_querier": true, + "emit_async_querier": true, + "inflection_exclude_table_names": [ + "my_data", + "exclusions" + ] + } + } + ] } ] } diff --git a/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/sqlc.json b/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/sqlc.json index a77f7de656..235db379e5 100644 --- a/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/sqlc.json +++ b/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/sqlc.json @@ -1,19 +1,31 @@ { "version": "2", + "plugins": [ + { + "name": "py", + "wasm": { + "url": "https://github.com/tabbed/sqlc-gen-python/releases/download/v0.16.0-alpha/sqlc-gen-python.wasm", + "sha256": "4fb54ee7d25b4d909b59a8271ebee60ad76ff17b10d61632a5ca5651e4bfe438" + } + } + ], "sql": [ { "schema": "query.sql", "queries": "query.sql", "engine": "postgresql", - "gen": { - "python": { + "codegen": [ + { + "plugin": "py", "out": "python", - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true, - "query_parameter_limit": -1 + "options": { + "package": "querytest", + "emit_sync_querier": true, + "emit_async_querier": true, + "query_parameter_limit": -1 + } } - } + ] } ] } diff --git a/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/stderr.txt b/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/stderr.txt index 2f0a7a559a..efed0cc10b 100644 --- a/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/stderr.txt +++ b/internal/endtoend/testdata/query_parameter_limit/-1/python_postgresql/stderr.txt @@ -1 +1,2 @@ -error parsing sqlc.json: invalid query parameter limit +# package py +error generating code: error generating output: invalid query parameter limit diff --git a/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/sqlc.json b/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/sqlc.json index a3c1bc6efa..3624786e96 100644 --- a/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/sqlc.json +++ b/internal/endtoend/testdata/query_parameter_limit/0/python_postgresql/sqlc.json @@ -1,19 +1,31 @@ { "version": "2", + "plugins": [ + { + "name": "py", + "wasm": { + "url": "https://github.com/tabbed/sqlc-gen-python/releases/download/v0.16.0-alpha/sqlc-gen-python.wasm", + "sha256": "4fb54ee7d25b4d909b59a8271ebee60ad76ff17b10d61632a5ca5651e4bfe438" + } + } + ], "sql": [ { "schema": "query.sql", "queries": "query.sql", "engine": "postgresql", - "gen": { - "python": { + "codegen": [ + { + "plugin": "py", "out": "python", - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true, - "query_parameter_limit": 0 + "options": { + "package": "querytest", + "emit_sync_querier": true, + "emit_async_querier": true, + "query_parameter_limit": 0 + } } - } + ] } ] } diff --git a/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/sqlc.json b/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/sqlc.json index 3ceaa5380f..583fad76be 100644 --- a/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/sqlc.json +++ b/internal/endtoend/testdata/query_parameter_limit/2/python_postgresql/sqlc.json @@ -1,19 +1,31 @@ { "version": "2", + "plugins": [ + { + "name": "py", + "wasm": { + "url": "https://github.com/tabbed/sqlc-gen-python/releases/download/v0.16.0-alpha/sqlc-gen-python.wasm", + "sha256": "4fb54ee7d25b4d909b59a8271ebee60ad76ff17b10d61632a5ca5651e4bfe438" + } + } + ], "sql": [ { "schema": "query.sql", "queries": "query.sql", "engine": "postgresql", - "gen": { - "python": { + "codegen": [ + { + "plugin": "py", "out": "python", - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true, - "query_parameter_limit": 2 + "options": { + "package": "querytest", + "emit_sync_querier": true, + "emit_async_querier": true, + "query_parameter_limit": 2 + } } - } + ] } ] } diff --git a/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/sqlc.json b/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/sqlc.json index ab1d93b949..606b57235b 100644 --- a/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/sqlc.json +++ b/internal/endtoend/testdata/query_parameter_limit/undefined/python_postgresql/sqlc.json @@ -1,18 +1,30 @@ { "version": "2", + "plugins": [ + { + "name": "py", + "wasm": { + "url": "https://github.com/tabbed/sqlc-gen-python/releases/download/v0.16.0-alpha/sqlc-gen-python.wasm", + "sha256": "4fb54ee7d25b4d909b59a8271ebee60ad76ff17b10d61632a5ca5651e4bfe438" + } + } + ], "sql": [ { "schema": "query.sql", "queries": "query.sql", "engine": "postgresql", - "gen": { - "python": { + "codegen": [ + { + "plugin": "py", "out": "python", - "package": "querytest", - "emit_sync_querier": true, - "emit_async_querier": true + "options": { + "package": "querytest", + "emit_sync_querier": true, + "emit_async_querier": true + } } - } + ] } ] } diff --git a/internal/ext/wasm/wasm.go b/internal/ext/wasm/wasm.go index 7a86c83b5f..5dee8831e7 100644 --- a/internal/ext/wasm/wasm.go +++ b/internal/ext/wasm/wasm.go @@ -8,6 +8,7 @@ import ( "context" "crypto/sha256" _ "embed" + "errors" "fmt" "io" "io/ioutil" @@ -252,6 +253,11 @@ func (r *Runner) Generate(ctx context.Context, req *plugin.CodeGenRequest) (*plu _, err = nom.Call(store) callRegion.End() if err != nil { + // Print WASM stdout + stderrBlob, err := os.ReadFile(stderrPath) + if err == nil && len(stderrBlob) > 0 { + return nil, errors.New(string(stderrBlob)) + } return nil, fmt.Errorf("call: %w", err) }