peewee 字段属性help_text的支持问题
至少在__version__ = '2.6.0'的时候,给字段添加help_text的时候,在数据库的ddl语句里面是没有comment的。
看了下源码,顺藤摸瓜,最终定位到了字段(Field类)的__ddl__函数, 源码这里。
如下:
def __ddl__(self, column_type):
"""Return a list of Node instances that defines the column."""
ddl = [self.as_entity(), self.__ddl_column__(column_type)]
if not self.null:
ddl.append(SQL('NOT NULL'))
if self.primary_key:
ddl.append(SQL('PRIMARY KEY'))
if self.sequence:
ddl.append(SQL("DEFAULT NEXTVAL('%s')" % self.sequence))
if self.constraints:
ddl.extend(self.constraints)
return ddl
ok,已经确定help_text没有真正实现。
很自然的想到,改一改,重新编译安装。看看官方文档,支持的数据库类型有: sqllite, mysql, postgresql
也就是说,建表时定义comment,至少要支持这三种数据库。
mysql建表时定义comment如下:
create table test(id int(11) comment 'test comment');
postgresql似乎无法在建表时定义字段的帮助信息,看这里。
sqllite不想看咯。
顺便一提,oracle是没有办法在建表的时候给字段添加注释的,参考这里。
因此,最多只能照顾到mysql。不想在这个层次折腾了。用sql(alter table xxx modify column column_definition comment '我的注释')写又要参照python代码里具体模型的定义,吐血中。
peewee 字段属性help_text的支持问题的更多相关文章
- Django之Models进阶操作(字段属性)
字段属性详细介绍 一.字段 AutoField(Field) - int自增列,必须填入参数 primary_key=True BigAutoField(AutoField) - bigint自增列, ...
- 1.4.2 solr字段类型--(1.4.2.7)字段属性使用案例
1.4.2 solr字段类型 (1.4.2.1) 字段类型定义和字段类型属性. (1.4.2.2) solr附带的字段类型 (1.4.2.3) 使用货币和汇率 (1.4.2.4) 使用Dates(日期 ...
- Django_ORM_字段属性
Django_ORM_字段属性 常用字段 AutoField int自增列,必填参 primary_key=True 默认会自动创建一个列名为id的列 IntegerField 一个整数类型,范围在 ...
- odoo字段属性
以下为可用的非关联字段类型以及其对应的位置参数: Char(string)是一个单行文本,唯一位置参数是string字段标签. Text(string)是一个多行文本,唯一位置参数是string字段标 ...
- 实例级别和类级别的static、构造函数、字段属性的简单介绍
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 实例级别 ...
- Java操作属性文件,支持新增或更新多个属性
Java操作属性文件.支持新增或更新多个属性 一.更新或新增单个属性的方法 /** * 写入properties信息 * @param filePath 绝对路径(包含文件名称和后缀名) * @par ...
- mysql学习(五)-字段属性
字段属性: unsigned: 无符号类型,只能修饰数值类型: create table if not exists t1(id int unsigned); zerofill:前端填0 //只能修饰 ...
- MySQL (三)-- 字段属性、索引、关系、范式、逆规范化
1 字段属性 主键.唯一键和自增长. 1.1 主键 主键:primary key,一张表中只能有一个字段可以使用对应的键,用来唯一的约束该字段里面的数据,不能重复. 一张表只能有最多一个主键. 1.1 ...
- ASP.NET Core教程【三】实体字段属性、链接标签、并发数据异常、文件上传及读取
前文索引:ASP.NET Core教程[二]从保存数据看Razor Page的特有属性与服务端验证ASP.NET Core教程[一]关于Razor Page的知识 实体字段属性 再来看看我们的实体类 ...
随机推荐
- Reading With Purpose: A grand experiment
Reading With Purpose: A grand experiment This is the preface to a set of notes I'm writing for a sem ...
- MacPorts安装32位动态库
http://superuser.com/questions/63198/install-32-bits-ports-on-snow-leopard
- dedecms标签的sql语句
{dede:sql sql='Select content from dede_arctype where id=1' titlelen='40′} [field:content/] {/dede:s ...
- Swift学习二
// 定义枚举方式一 enum Season { // 每个case定义一个实例 case Spring case Summer case Fall case Winter } // 定义枚举方式二 ...
- 替换所有的cell的右侧箭头
写个UITableViewCell的分类重写这个方法 - (void)didMoveToSuperview { [super didMoveToSuperview]; // 全局替换右侧箭头 if ( ...
- vnc服务器配置实例
系统环境为CentOS.RHEL. 临时需要远程连接,参考:http://www.centoscn.com/CentOS/Intermediate/2013/0917/1641.html 一.安装.启 ...
- Http常用状态码
HTTP状态码(HTTP Status Code) 一些常见的状态码为: 200 - 服务器成功返回网页 404 - 请求的网页不存在 503 - 服务不可用 所有状态解释:点击查看 1xx(临时响应 ...
- Database Initialization Strategies in Code-First:
You already created a database after running your Code-First application the first time, but what ab ...
- python递归理解图
递归:下一级只能return给自己的上一级. import re val="9-2*5/3+7/3*99/4*2998+10*568/14" val="9-2*5/3+7 ...
- .NET对象判等归纳与总结
1.引言 最近在看<CLR via C#>看到对象判等的那一节,觉得这也是.NET基础知识中比较重要的部分就写一篇博文来简单的总结归纳一下. 2..NET下的对象判等 在.NET中关于对象 ...