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 ...
随机推荐
- 七种经典排序算法及Java实现
排序算法稳定性表示两个值相同的元素在排序前后是否有位置变化.如果前后位置变化,则排序算法是不稳定的,否则是稳定的.稳定性的定义符合常理,两个值相同的元素无需再次交换位置,交换位置是做了一次无用功. 下 ...
- app性能测试,你需要关注哪些指标?
app性能测试,你需要关注哪些指标? 一.Android客户端性能测试常见指标: 1.内存 2.CPU 3.流量 4.电量 5.启动速度 6.滑动速度.界面切换速度 7.与服务器交互的网络速度 二.预 ...
- [Swift]LeetCode67. 二进制求和 | Add Binary
Given two binary strings, return their sum (also a binary string). The input strings are both non-em ...
- [Swift]LeetCode146. LRU缓存机制 | LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the fol ...
- [Swift]LeetCode453. 最小移动次数使数组元素相等 | Minimum Moves to Equal Array Elements
Given a non-empty integer array of size n, find the minimum number of moves required to make all arr ...
- [Swift]LeetCode643. 子数组最大平均数 I | Maximum Average Subarray I
Given an array consisting of n integers, find the contiguous subarray of given length k that has the ...
- PHP实现登录注册
一.首先实现一个PHP的简单登录注册的话 我们要简单的与后端定义一下接口和传输数据的方式 并且我们要有一个phpStudy服务器. 第一步:当我们点击注册按钮的时候数据库要接收到客户端请求的数据 第 ...
- python3+ selenium3开发环境搭建-手把手教你安装python(详细)
环境搭建 基于python3和selenium3做自动化测试,俗话说:工欲善其事必先利其器:没有金刚钻就不揽那瓷器活,磨刀不误砍柴工,因此你必须会搭建基本的开发环境,掌握python基本的语法和一个I ...
- 极速搭建RTMP直播流服务器+webapp (vue) 简单实现直播效果
在尝试使用webRTC实现webapp直播失败后,转移思路开始另外寻找可行的解决方案.在网页上尝试使用webRTC实现视频的直播与看直播,在谷歌浏览器以及safari浏览器上测试是可行的.但是基于基座 ...
- EF三种编程方式图文详解
Entity Framework4.1之前EF支持“Database First”和“Model First”编程方式,从EF4.1开始EF开始支持支持“Code First”编程方式,今天简单看一下 ...