Comments (3)
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.
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.
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)
- refine make built-in function allocates add len HOT 2
- usertoken HOT 1
- pass in dbtest tokenv1 HOT 1
- user role question HOT 4
- More complicated role HOT 2
- Unit test HOT 5
- layer called userapp! HOT 4
- error when run multiple instances HOT 1
- Why, when we want to edit a field or change its type, the changes are not applied in the database with the migration command. HOT 7
- Tests HOT 5
- Question: Respond before commit transaction HOT 3
- Add account verification link HOT 3
- Transaction error 500 when testing transaction with validation error 400 HOT 2
- Code generates HOT 1
- Question: API integration HOT 2
- It is suggested to improve the naming of returned errors from the database layer HOT 1
- Question about vproduct domain HOT 2
- Question about pointer semantic HOT 1
- Question about logger HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from service.