Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: build build-endtoend test test-ci test-examples test-endtoend start psql mysqlsh proto
.PHONY: build build-endtoend test test-ci test-examples test-endtoend start psql mysqlsh proto sqlc

build:
go build ./...
Expand All @@ -23,17 +23,20 @@ build-endtoend:

test-ci: test-examples build-endtoend vet

sqlc:
go build -o ./bin/sqlc ./cmd/sqlc/

sqlc-dev:
go build -o ~/bin/sqlc-dev ./cmd/sqlc/
go build -o ./bin/sqlc-dev ./cmd/sqlc/

sqlc-pg-gen:
go build -o ~/bin/sqlc-pg-gen ./internal/tools/sqlc-pg-gen
go build -o ./bin/sqlc-pg-gen ./internal/tools/sqlc-pg-gen

sqlc-gen-json:
go build -o ~/bin/sqlc-gen-json ./cmd/sqlc-gen-json
go build -o ./bin/sqlc-gen-json ./cmd/sqlc-gen-json

test-json-process-plugin:
go build -o ~/bin/test-json-process-plugin ./scripts/test-json-process-plugin/
go build -o ./bin/test-json-process-plugin ./scripts/test-json-process-plugin/

start:
docker compose up -d
Expand Down
2 changes: 2 additions & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
22 changes: 20 additions & 2 deletions internal/compiler/output_columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ func (c *Compiler) outputColumns(qc *QueryCatalog, node ast.Node) ([]*Column, er

targets := &ast.List{}
switch n := node.(type) {
case *ast.CallStmt:
fun, err := qc.catalog.ResolveFuncCall(n.FuncCall)
if err != nil {
return nil, err
}
var cols []*Column
for _, arg := range fun.Args {
if arg.Mode == ast.FuncParamOut || arg.Mode == ast.FuncParamInOut || arg.Mode == ast.FuncParamTable {
name := arg.Name
typeName := arg.Type.Name
if arg.Type.Names != nil && len(arg.Type.Names.Items) > 0 {
typeName = astutils.Join(arg.Type.Names, ".")
} else if arg.Type.Schema != "" {
typeName = arg.Type.Schema + "." + arg.Type.Name
}
cols = append(cols, &Column{Name: name, DataType: typeName, NotNull: false})
}
}
return cols, nil
case *ast.DeleteStmt:
targets = n.ReturningList
case *ast.InsertStmt:
Expand Down Expand Up @@ -580,8 +599,7 @@ func (c *Compiler) sourceTables(qc *QueryCatalog, node ast.Node) ([]*Table, erro
DataType: arg.Type.Name,
})
}
}
if fn.ReturnType != nil {
} else if fn.ReturnType != nil {
table.Columns = []*Column{
{
Name: colName,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- name: SelectAll :many
SELECT * FROM public.get_test();

-- name: SelectWithTime :many
SELECT * FROM public.get_test($1::timestamp);
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- Create mock test table
create table if not exists public.test_data
(
test_id integer,
test_date date,
test_time timestamp with time zone,
test_string text,
test_varchar character varying,
test_double double precision
);

create function public.get_test(input_time timestamp without time zone DEFAULT now())
returns TABLE
(
test_id integer,
test_date date,
test_time timestamp with time zone,
test_string text,
test_varchar character varying,
test_double double precision
)
stable
language sql
as
$$
SELECT test_id,
test_date,
test_time,
test_string,
test_varchar,
test_double
FROM public.test_data
WHERE test_time <= input_time
$$;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "1",
"packages": [
{
"path": "go",
"engine": "postgresql",
"sql_package": "pgx/v5",
"name": "querytest",
"schema": "schema.sql",
"queries": "query.sql"
}
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading