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

输出的struct中的字段按字母排序而不是数据库的字段顺序 #13

Closed
beijibeijing opened this issue May 17, 2020 · 20 comments
Assignees
Labels
enhancement New feature or request

Comments

@beijibeijing
Copy link

hi,如题,输出的struct中的字段按字母排序而不是数据库的字段顺序。
是我的设置问题么,还是可以优化下?

@hantmac hantmac self-assigned this May 17, 2020
@hantmac hantmac added the enhancement New feature or request label May 17, 2020
@hantmac
Copy link
Owner

hantmac commented May 17, 2020

hi,如题,输出的struct中的字段按字母排序而不是数据库的字段顺序。
是我的设置问题么,还是可以优化下?

目前确实是按照字母顺序排序的,我看看能否优化一下。Thanks!

@hantmac
Copy link
Owner

hantmac commented May 17, 2020

已经 fix 了,执行 brew uninstall fuckdb && brew tap hantmac/tap && brew install fuckdb 升级到最新版本就可以指定 struct 字段的顺序了,默认按照数据库顺序 🍺

@hantmac
Copy link
Owner

hantmac commented May 20, 2020

@beijibeijing 有时间的话帮忙验证下哈,没什么问题我就 close issue

@beijibeijing
Copy link
Author

更新中,待会测下,另外问个问题,注释不能一起导出来么?

@hantmac
Copy link
Owner

hantmac commented May 21, 2020

@beijibeijing 是指数据库的注释(comment)吗?

@beijibeijing
Copy link
Author

没用brew安装直接clone下来,前端build了下然后go环境里跑的,还是按字母排序啊;
是的数据库的注释(comment)。
辛苦~

@hantmac
Copy link
Owner

hantmac commented May 21, 2020

  1. 拉最新的代码试一下;
  2. struct 里包含数据库的 comment 感觉没什么用呀?这个 comment 你是想要放在 struct 代码的哪个位置?

@beijibeijing
Copy link
Author

2.放到//后面。。。。。。。只看代码的代码同学,就知道啥意思了啊,不用去数据库或者另看文档了

@hantmac
Copy link
Owner

hantmac commented May 21, 2020

有道理,周末有时间看看这个问题;

ps: 我感觉命令行更加灵活,可以试下命令行

@yann0917
Copy link

我 fork 了一份,大改了作者源码,新增了输出 Markdown, json, txt, csv格式,导出数据字典很方便:https://github.com/yann0917/fuckdb

输出 markdown 格式举例(符合我公司的数据字典格式,使用 hugo 生成静态页面):


title: common_config - 公共的配置
weight: 100

结构

字段 数据类型 索引 默认值 备注
id int(11) unsigned PRI 主键ID
keyword varchar(64) 关键词
value text
type tinyint(1) 0 是否需要jwt验证
remark varchar(255) 描述
created_at timestamp 创建时间
updated_at timestamp CURRENT_TIMESTAMP 更新时间
deleted_at timestamp 删除时间

SQL

CREATE TABLE `common_config` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `keyword` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '关键词',
  `value` text COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '',
  `type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否需要jwt验证',
  `remark` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '描述',
  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted_at` timestamp NULL DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='公共的配置'

updateSQL

@hantmac
Copy link
Owner

hantmac commented Jun 20, 2020

@yann0917 哇看起来很棒,方便的话可以贡献这些代码吗?我想在命令行里也支持生成这些格式。

@yann0917
Copy link

@yann0917 哇看起来很棒,方便的话可以贡献这些代码吗?我想在命令行里也支持生成这些格式。

完全可以啊,我提 PR 吗?

@hantmac
Copy link
Owner

hantmac commented Jun 20, 2020

@yann0917 哇看起来很棒,方便的话可以贡献这些代码吗?我想在命令行里也支持生成这些格式。

完全可以啊,我提 PR 吗?

没问题的,来吧 😄

@yann0917
Copy link

@yann0917 哇看起来很棒,方便的话可以贡献这些代码吗?我想在命令行里也支持生成这些格式。

完全可以啊,我提 PR 吗?

没问题的,来吧 😄

我改动太大了,完全冲突了,没法提 PR 😭
image

@hantmac
Copy link
Owner

hantmac commented Jun 20, 2020

@yann0917 确实是,不然就重新 fork ,然后再写一遍,然后按功能提交?或者我看下你代码,我来加也行🤔

@yann0917
Copy link

yann0917 commented Jun 20, 2020

@yann0917 确实是,不然就重新 fork ,然后再写一遍,然后按功能提交?或者我看下你代码,我来加也行🤔

我重新建了个develop 分支,这个分支合并了冲突,但是把你 master 的分支回滚到了 5月14号🤔 ,web 页面的功能应该是完全兼容的,命令行的我用不到,就没重构这部分(应该有错),你看下。

@hantmac
Copy link
Owner

hantmac commented Jun 20, 2020

@yann0917 那次回滚的原因是我把二进制文件提交到了 Git 上,导致整个 repo 的体积太大,所以就回滚处理了一下,所以你应该 rebase 一把,不然还会把之前的大体积提交带进来

@yann0917
Copy link

@yann0917 那次回滚的原因是我把二进制文件提交到了 Git 上,导致整个 repo 的体积太大,所以就回滚处理了一下,所以你应该 rebase 一把,不然还会把之前的大体积提交带进来

其实不是回滚,是 merge,解决的冲突

@hantmac
Copy link
Owner

hantmac commented Jun 20, 2020

@yann0917 那次回滚的原因是我把二进制文件提交到了 Git 上,导致整个 repo 的体积太大,所以就回滚处理了一下,所以你应该 rebase 一把,不然还会把之前的大体积提交带进来

其实不是回滚,是 merge,解决的冲突

是的

@hantmac
Copy link
Owner

hantmac commented Jul 1, 2020

已合入 develop

@hantmac hantmac closed this as completed Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants