Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@id is not friendly to insert map struct #7075

Open
zh929 opened this issue Jun 20, 2024 · 1 comment
Open

@id is not friendly to insert map struct #7075

zh929 opened this issue Jun 20, 2024 · 1 comment
Assignees
Labels

Comments

@zh929
Copy link

zh929 commented Jun 20, 2024

GORM Playground Link

go-gorm/playground#739

Description

The data does not exist in multiple databases,and i just know the map struct, i want insert the data into multiple databases.

if I use createForUpdate logic,and the same logic is executed simultaneously in multiple databases,if not set Model, just know the table name. the same map will add “@id”,causing some SQL statements to fail execution.

For example:
`

    updateList := make([]map[string]interface{}, 0)  // the map will be add '@id'   

    columns := make([]clause.Column, 0)    

    updateColumns := make([]string, 0)  

 for _, v := range req.dbList {   
                   dbName := v

		db := global.GVA_DBList[dbName]  

		err := db.Table(req.table).Clauses(clause.OnConflict{  

			Columns:   columns,  
                            
			DoUpdates: clause.AssignmentColumns(updateColumns),   

		}).Create(&updateList).Error  
		if err != nil {  
			errDbList = append(errDbList, dbName)  
			isAllDone = false  
		}  
}  

`
Error Msg: Error 1054 (42S22): Unknown column '@id' in 'field list'

Will the same issue also occur during insert, This is not very compatible with old versions.

@github-actions github-actions bot added the type:missing reproduction steps missing reproduction steps label Jun 20, 2024
Copy link

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.ioSearch Before Asking

@github-actions github-actions bot added status:stale type:with reproduction steps with reproduction steps and removed type:missing reproduction steps missing reproduction steps labels Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants