Giter Club home page Giter Club logo

Comments (3)

ardan-bkennedy avatar ardan-bkennedy commented on August 10, 2024 1

No worries. I'm happy you asked the question and don't ever stop questioning things when they don't make sense.

I didn't notice they added this package to the module we already import. That is super confusing to have this package in two places. It wasn't necessary a bad idea, but I only use pgx for the driver. I am using sqlx to actually interact with the DB.

from service.

ardan-bkennedy avatar ardan-bkennedy commented on August 10, 2024

Where is the definition of this type pgtype.Text? Are you are talking about this package?

https://github.com/jackc/pgtype

If you are suggesting to bring this package in just for a single type and not for any of its behavior. I'm not a fan of that.

We have a NULL type in the standard library sql.Null that I do use when NULL is a valid option for a field.

type user struct {
	ID           uuid.UUID      `db:"user_id"`
	Name         string         `db:"name"`
	Email        string         `db:"email"`
	Roles        dbarray.String `db:"roles"`
	PasswordHash []byte         `db:"password_hash"`
	Department   sql.NullString `db:"department"`
	Enabled      bool           `db:"enabled"`
	DateCreated  time.Time      `db:"date_created"`
	DateUpdated  time.Time      `db:"date_updated"`
}

What is the problem with using sql.Null. We have the to functions to perform the data transformation between the layers.

from service.

Dodje avatar Dodje commented on August 10, 2024

Yeah, I've found it in the service project github.com/jackc/pgx/v5/.
So I made a use of github.com/jackc/pgx/v5/pgtype to work with geopoints pgtype.Point. That's why I've got an idea to use pgtypes for postgres oriented structs..

What is the problem with using sql.NullString

Actually that's kinda my mistake. I'm a newbie in go, so I now feel ashamed about not knowing about such simple things...)

Thank you for the quick and very useful repsonse!

from service.

Related Issues (20)

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.