Code Monkey home page Code Monkey logo

pbpgx's People

Contributors

muhlemmer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

wfen

pbpgx's Issues

Should I continue on this lib

I have doubts to continue work on this library. To be honest, since I started pgx v5 came out which now features excellent mechanics to scan directly into struct types including nesting of rows etc. Hence, I don't see much value in regards to scanning into protobuffer messages specifically. Also the architecture at my current employer is mostly incompatible with what I tried to do here, so there is no incentive to support this work at the moment.

The query building part was nice to do and I spend quite some time optimizing it. So there arises my doubt :)

There are just 11 Github stars, for which I'm grateful. Please let me know if there are any real usecases out there already and I will make up my mind based on feedback. Cheers!

Drop the selector interface

The selector interface puts too much limits on the callers. Instead, just use generic arguments for ID and columns.

pbpgx/crud/read.go

Lines 32 to 46 in 0cde4e5

type Selector[ID any, ColDesc fmt.Stringer] interface {
proto.Message
// GetId may return any type for ID.
// The returned value will be used as-is as unique identifier in the "id"
// column of the table being accessed.
// The type must by compatible with the PostgreSQL type of the "id" column.
// This method is ussualy generated for proto messages with an `id` field defined.
GetId() ID
// GetColumns returns a slice of fmt.Stringer, as column descriptors.
// This method is ussualy generated for proto messages with a `columns` field defined.
// This field should be a "repeated enum" type. Each enum value equals a column name.
GetColumns() []ColDesc
}

crud: false NoRows error returned if other error occurs

record, err = pbpgx.QueryRow[Record](ctx, x, qs, args...)

Executing the INSERT...RETURNING query which fails to insert, the returned error is pgx.ErrNoRows, while it should be the original error:

6:27PM ERR Query args=[{"ValueTranscoder":"muhlemmer"},{"ValueTranscoder":"[email protected]"}] err="ERROR: duplicate key value violates unique constraint \"users_email_key\" (SQLSTATE 23505)" module=pgx pid=373 sql="INSERT INTO \"account\".\"users\" (\"nickname\", \"email\") VALUES ($1, $2) RETURNING \"email\", \"nickname\", \"updated_at\", \"created_at\", \"id\";"
panic: Table "account"."users" Create[0]: no rows in result set

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.