Skip to content
forked from jschaf/pggen

Generate type-safe Go for any Postgres query. If Postgres can run the query, pggen can generate code for it.

License

Notifications You must be signed in to change notification settings

robbert229/pggen

 
 

Repository files navigation

test lint GoReportCard

Notice

This is a temporary fork that I have been working on with the intention of backporting the changes to the upstream pggen. It is not fully functional.

Changes

Because of the changes in how types are managed in v4 compared to v5, type registration needs to be configured in the AfterConnect function on the pgx config.

dbconfig, err := pgxpool.ParseConfig(databaseURL)
if err != nil {
	// handle error
}

dbconfig.AfterConnect = func(ctx context.Context, pgconn *pgconn.PgConn) error {
    err := your_gen_pkg.Register(ctx, pgconn)
    if err != nil {
        return fmt.Errorf("failed to register types: %w", err)
    }

    return nil
}

Features Supported

The following examples compile, and are implemented.

  • example/author
  • example/domain
  • example/go_pointer_types
  • example/inline_param_count
  • example/pgcrypto
  • example/slices
  • example/syntax
  • example/custom_types
  • example/enums
  • example/device
  • example/function
  • example/separate_out_dir/out
  • example/erp/order
  • example/ltree
  • example/void
  • example/composite

Feature Unsupported

  • example/citext
  • example/nested
  • example/complex_params

About

Generate type-safe Go for any Postgres query. If Postgres can run the query, pggen can generate code for it.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 98.4%
  • Other 1.6%