SQLite3 DB

user.go

package database

import (
    "fmt"
    "infohubserver/internal/utils"
    "strconv"

    "golang.org/x/text/cases"
    "golang.org/x/text/language"
    "gorm.io/gorm"
)

type User struct {
    //Main columns
    UserId        uint   `gorm:"autoIncrement;primaryKey;not null;unique" json:"userId"`
    UserFirstName string `gorm:"not null" json:"userFirstName"`
    UserLastName  string `gorm:"not null" json:"userLastName"`
    UserInitial   string `gorm:"not null" json:"userInitial"`
    UserUsername  string `gorm:"not null;unique;<-:create" json:"userUsername"`
    UserPassword  string `gorm:"not null" json:"userPassword"` //Encrypted password
    UserRole      string `gorm:"not null" json:"userRole"`
    UserAvatarImg []byte `gorm:"default:NULL" json:"userAvatarImg"`
    //For form submiting value or extra info only (Will not be recorded in database)
    Password     string `gorm:"-:all" json:"password"`
    UserFullName string `gorm:"-:all" json:"userFullName"`
}

Error:

2022/08/31 14:30:50 C:/Users/vho/go/pkg/mod/gorm.io/driver/sqlite@v1.3.6/migrator.go:416 near ")": syntax error
[0.000ms] [rows:0] INSERT INTO `users__temp`() SELECT  FROM `users`

When no existing Users table, Gorm works without any error. But I would like to keep existing data in my table tho.

I am not sure what causing Gorm to generate the invalid syntax like that. The existing Users table only have a few data in it.

Please help!

Originally posted by @KiddoV in https://github.com/go-gorm/gorm/discussions/5664

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: KiddoV

Answer: https://github.com/go-gorm/gorm/discussions/5664#discussioncomment-3528181