Closed aryanmehrotra closed 1 week ago
@aryanmehrotra, The uuid.UUID type can be used, but to ensure compatibility with the database, the id field should be defined as a CHAR(36) or VARCHAR(36) data type while creating table schema in database, rather than an INT, since UUIDs are stored as 36-character strings. Here is an example :
Defined type :
type User struct {
Id uuid.UUID `json:"id"` // CHAR(36) or VARCHAR(36) in SQL
Name string `json:"name"` // VARCHAR(n) or TEXT in SQL
Age int `json:"age"` // INT in SQL
}
SQL Table Schema :
CREATE TABLE users (
id CHAR(36) PRIMARY KEY,
name VARCHAR(255),
age INT
);
This issue can now be considered resolved.
When a struct has fields of type int, string, bool those are supported for operations, we need to support uuid type as well.