Tips on GORM, Avoid Error about "duplicate column name: id"
The GORM is an super easy ORM solution for Go language.
But many people would get the error about
duplicate column name: id
Usually this comes from the model definition which has duplicated ID,
package model import (
"github.com/jinzhu/gorm"
) type Job struct {
gorm.Model // Already has ID, CreatedAt, UpdatedAt, DeletedAt 4 fields
Name string
}
We could remove the ID definition from our code and only use the one from grom.Model, or don't use the gorm.Model at all.
Tips on GORM, Avoid Error about "duplicate column name: id"的更多相关文章
- java PageHelper 分页插件出现 Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Duplicate column name 'Id' 错误
情景: Mapper.xml定义连表查询,如果sql的字段名中有sql关键字,会导致PageHelper插件出现 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntax ...
- Using innodb_large_prefix to avoid ERROR #1071,Specified key was too long; max key length is 1000 bytes
Using innodb_large_prefix to avoid ERROR 1071 单列索引限制上面有提到单列索引限制767,起因是256×3-1.这个3是字符最大占用空间(ut ...
- [o] duplicate column name: _id 问题解决
Android下使用SQLite数据库,报错:duplicate column name: _id 数据库文件下有两列数据的名称一样,原因是定义数据类型时有重复,如,我的定义: //复制上一行增加TY ...
- Duplicate column name 'vocabulary'
创建一个视图: 报错:Duplicate column name 'vocabulary' 意思是视图select的列名重复了,取别名 改成这样就ok了
- MySQL报错ERROR 1558 (HY000): Column count of mysql.user is wrong.
MySQL报错ERROR 1558 (HY000): Column count of mysql.user is wrong. 1.今天在使用MySQL创建数据库时出现如下报错: mysql> ...
- ERROR 3009 (HY000): Column count of mysql.user is wrong…..
在测试备份还原时,使用XtraBackup还原数据库后,创建一个测试账号时遇到了下面错误: mysql> grant all on house.* to test@'192.168.%' ide ...
- ERROR 3009 (HY000): Column count of mysql.user is wrong. Expected 45, found 42. Created with MySQL 50560, now running 50725. Please use mysql_upgrade to fix this error.
centos7.5 登入mysql,进行授权报错 问题: mysql> grant all privileges on *.* to 'lvhanzhi'@'%' identified by ' ...
- 表结构变更后出现的ERROR OGG-01161 Bad column index (88)
2014-07-31 09:38:31 ERROR OGG-01668 PROCESS ABENDING. 2014-07-31 09:38:31 ERROR OGG-01161 Bad column ...
- ERROR 3009 (HY000): Column count of mysql.user is wrong. Expected 45, found 43. Created with MySQL 5
ERROR 3009 (HY000): Column count of mysql.user is wrong. Expected 45, found 43. Created with MySQL 5 ...
随机推荐
- 脚本语言丨Batch入门教程第三章:逻辑判断
通过学习Batch入门教程的前两章内容,我们已经大致掌握了基本概念和认识变量的相关内容,今天我们要跟大家继续分享第三章内容:Batch入门教程之逻辑判断. 前期回顾 ◀Batch入门教程丨部署与H ...
- [Swift]LeetCode477. 汉明距离总和 | Total Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits ...
- [Swift]LeetCode687. 最长同值路径 | Longest Univalue Path
Given a binary tree, find the length of the longest path where each node in the path has the same va ...
- [Swift]LeetCode892. 三维形体的表面积 | Surface Area of 3D Shapes
On a N * N grid, we place some 1 * 1 * 1 cubes. Each value v = grid[i][j] represents a tower of v cu ...
- [Swift]LeetCode904. 水果成篮 | Fruit Into Baskets
In a row of trees, the i-th tree produces fruit with type tree[i]. You start at any tree of your cho ...
- [Swift]LeetCode997. 找到小镇的法官 | Find the Town Judge
In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is se ...
- postgresql 基础sql
创建用户和密码:crate user 用户名 with password '密码' : 创建 alter user 用户名 with password ’密码' ; 修改用户密码 查看用户信息: se ...
- DMA的基本概念
DMA允许外围设备和主内存之间直接传输 I/O 数据, DMA 依赖于系统.每一种体系结构DMA传输不同,编程接口也不同. 数据传输可以以两种方式触发:一种软件请求数据,另一种由硬件异步传输. 在第一 ...
- mac连接windows远程桌面及文件复制
最近更换mac办公,但由于之前是用windows,所以很多文件项目之类的东西都还在windows电脑中,一次都传到mac上又会比较占内存,并且使用率也不高,感觉不划算.但每次想用的时候,在从windo ...
- hadoop分布式搭建
1.新建三台机器,分别为: hadoop分布式搭建至少需要三台机器: master extension1 extension2 本文利用在VMware Workstation下安装Linux cent ...