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 ...
随机推荐
- PHPWord导出word文档
最近接了个把数据导出到word文档的需求,之前一直都是使用PHPExcel库导出excel的,还是头次接到导出到word文档的需求,我想既然有PHPExcel,那么肯定也会有PHPWord库吧,在网上 ...
- [Swift]LeetCode672. 灯泡开关 Ⅱ | Bulb Switcher II
There is a room with n lights which are turned on initially and 4 buttons on the wall. After perform ...
- [Swift]LeetCode799. 香槟塔 | Champagne Tower
We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so ...
- [Swift]LeetCode849. 到最近的人的最大距离 | Maximize Distance to Closest Person
In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is emp ...
- Nginx 动静分离与负载均衡的实现
一.前提 企业中,随着用户的增长,数据量也几乎成几何增长,数据越来越大,随之也就出现了各种应用的瓶颈问题. 问题出现了,我们就得想办法解决,一般网站环境,均会使用LAMP或者LNMP,而我们对于网站环 ...
- chmod命令相关
原文地址:https://www.jianshu.com/p/862a9938cc09 chmod命令用于修改文件的权限. Linux文件的三种身份和四种权限 三种身份 u:文件的拥有者: g:文件所 ...
- Django+Bootstrap+Mysql 搭建个人博客(三)
3.1.分页功能 (1)views.py from django.core.paginator import Paginator,EmptyPage,PageNotAnInteger def make ...
- phpStrom映射代码
- Django的静态资源
如果你的静态资源是某个APP专属,那么就在这个APP目录下建立一个static目录,就像上图report这个APP中的static目录.当浏览这个APP的网页时它会从这里去找资源,当然,它首先会从共用 ...
- Flow 常用知识点整理
Flow入门初识 Flow是facebook出品的JavaScript静态类型检查工具. 由于JavaScript是动态类型语言,它的灵活性也会造成一些代码隐患,使用Flow可以在编译期尽早发现由类型 ...