Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Procedure code generation may have issues #384

Open
adpande opened this issue Dec 31, 2022 · 1 comment
Open

Procedure code generation may have issues #384

adpande opened this issue Dec 31, 2022 · 1 comment

Comments

@adpande
Copy link

adpande commented Dec 31, 2022

first thanks for the wonderful library. I got an issue with the code generated for a procedure.

xo generated following code for my procedure. My DB is PostgreSQL 14

Procedure

create function update_updated_at_column() returns trigger
    language plpgsql
as
$$
BEGIN
    NEW.updated_at= now();
RETURN NEW;
END;
$$;

alter function update_updated_at_column() owner to abhishek;


Generated go code:

package xodb

// Code generated by xo. DO NOT EDIT.

import (
	"context"
)

// UpdateUpdatedAtColumn calls the stored function 'public.update_updated_at_column() trigger' on db.
func UpdateUpdatedAtColumn(ctx context.Context, db DB) (Trigger, error) {
	// call public.update_updated_at_column
	const sqlstr = `SELECT * FROM public.update_updated_at_column()`
	// run
	var r0 Trigger
	logf(sqlstr)
	if err := db.QueryRowContext(ctx, sqlstr).Scan(&r0); err != nil {
		return Trigger{}, logerror(err)
	}
	return r0, nil
}

If you see the Trigger structure is not generated and the code fails to compile. I think it is a bug in code generation but can not figure out in the templates. Please help.

Thanks & Regards,
Abhi

@SC4RECOIN
Copy link

same issue for me

is there a way to disable this code generation temporarily ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants