[BEST PRACTICE] To use with unique identifier
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 431
- Forks
- 44
- Avg merge
- 21h 18m
- Merged PRs (30d)
- 30
Description
Hello, guys. Thanks for this project be public.
I have a question about best case to uses with mssql.uniqueidentifier.
This is a small example of my struct and crud operations. I use bun to connect to database
type SomeStruct struct {
ID int `bun:"id"`
ExternalId mssql.UniqueIdentifier `bun:"externalid"`
IdPost int `bun:"id_post"`
IdAvatar int `bun:"id_avatar"`
}
func (someStruct *SomeStruct) MarshalJSON() ([]byte, error) {
type Alias SomeStruct
return json.Marshal(&struct {
ID string `json:"id"`
*Alias
}{
ID: someStruct.ExternalId.String(),
Alias: (*Alias)(someStruct),
})
}
I need use externalId as string everywhere at my project. And i need to cast mssql uniqueidentifier to string like i do at MarshalJson func. Is there a best practice to handle this without uses conversion everytime? I am thinking about change the unique identifier column to string. But i will lost much funcionalities of unique identifier be managed by sql server.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file, test, or entry point is named; start by reviewing the Go struct, MarshalJSON method, and mssql.UniqueIdentifier usage shown in the issue. A useful outcome would require an agreed approach for exposing the identifier as a string while retaining the SQL Server uniqueidentifier column, with documentation or tests demonstrating it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- database
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100