refactor: improve flexibility and project structure #28

Merged
lunny merged 9 commits from weakptr/reverse:refactor/improve-flexibility-and-project-structure into master 2021-06-14 14:17:18 +00:00
Contributor

目的和变更概述

  1. 项目目录结构调整,贴近但不完全照搬 golang-standards/project-layout,提供更清晰的目录结构
  2. language 结构改为 interface 以提供更好的扩展性和可读性;language 接口支持绑定 target,便于 language 接口提供的 FuncMap 等工具能根据 target 的配置来改变自己的行为,扩展性更好
  3. 分离配置结构和反序列化方法到单独的包 pkg/conf ,使目录结构和代码更清晰可读
  4. 提供多 document 的 yaml 支持,方便要处理多个数据源的场景
  5. 添加 underscore ,没什么特别的理由,主要是这套函数式的工具真的很好用,能提高代码可读性;但 underscore 这个库也有问题,因为没泛型全靠 reflect 一把梭,underscore 内部报 reflect 相关错误会比较难排查处理。
  6. 添加 column_name 选项,生成字段 ID int64 xorm:"id pk autoincr"` 这样的 tag,显式建立结构字段名和列名的映射关系。参见 #27
目的和变更概述 1. 项目目录结构调整,贴近但不完全照搬 [golang-standards/project-layout](https://github.com/golang-standards/project-layout),提供更清晰的目录结构 2. language 结构改为 interface 以提供更好的扩展性和可读性;language 接口支持绑定 target,便于 language 接口提供的 FuncMap 等工具能根据 target 的配置来改变自己的行为,扩展性更好 3. 分离配置结构和反序列化方法到单独的包 `pkg/conf` ,使目录结构和代码更清晰可读 4. 提供多 document 的 yaml 支持,方便要处理多个数据源的场景 5. 添加 underscore ,没什么特别的理由,主要是这套函数式的工具真的很好用,能提高代码可读性;但 underscore 这个库也有问题,因为没泛型全靠 reflect 一把梭,underscore 内部报 reflect 相关错误会比较难排查处理。 6. 添加 `column_name` 选项,生成字段 `ID int64 `xorm:"id pk autoincr"` 这样的 tag,显式建立结构字段名和列名的映射关系。参见 [#27](https://gitea.com/xorm/reverse/issues/27)
weakptr added 1 commit 2021-06-08 08:59:10 +00:00
lunny added the
feature
label 2021-06-08 11:48:13 +00:00
weakptr added 1 commit 2021-06-14 05:28:09 +00:00
feat(conf): support explicit column name mapping switch
Some checks failed
continuous-integration/drone/pr Build is failing
3ed66f5247
weakptr added 3 commits 2021-06-14 06:48:22 +00:00
weakptr added 2 commits 2021-06-14 06:52:12 +00:00
Author
Contributor

添加了一些测试,覆盖了:

  • 单文档 YAML 最简配置
  • 多文档 YAML 配置
  • include_tables
  • exclude_tables
  • table_name
  • column_name

@lunny

添加了一些测试,覆盖了: - 单文档 YAML 最简配置 - 多文档 YAML 配置 - include_tables - exclude_tables - table_name - column_name @lunny
Owner

Thanks for your contribution. One small nit, could you add an example and test for multiple targets?

And when ColumnName is true, you should use single quote to avoid conflict with reversed word of xorm. i.e. xorm:"'column_name'"

Thanks for your contribution. One small nit, could you add an example and test for multiple targets? And when `ColumnName` is true, you should use single quote to avoid conflict with reversed word of xorm. i.e. `xorm:"'column_name'"`
weakptr added 1 commit 2021-06-14 11:12:11 +00:00
weakptr force-pushed refactor/improve-flexibility-and-project-structure from 74004dad07 to 8aef3d534c 2021-06-14 11:12:53 +00:00 Compare
Author
Contributor

Thanks for your contribution. One small nit, could you add an example and test for multiple targets?

And when ColumnName is true, you should use single quote to avoid conflict with reversed word of xorm. i.e. xorm:"'column_name'"

okay. fixed.

> Thanks for your contribution. One small nit, could you add an example and test for multiple targets? > > And when `ColumnName` is true, you should use single quote to avoid conflict with reversed word of xorm. i.e. `xorm:"'column_name'"` okay. fixed.
lunny merged commit 8c0b7497de into master 2021-06-14 14:17:18 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/reverse#28
No description provided.