如何按序提取出func (session *Session) QueryInterface(sqlOrArgs ...interface{})返回的字段名列表?
#2009
Closed
opened 1 year ago by ankisme
·
1 comments
No Branch/Tag Specified
Nanyan/master
add_on_update
cantasci/added_mssql_pagination_feature
chenghuama/master
in-han/master
liuchenrang/master
lunny/belongs_to2
lunny/clickhouse
lunny/db2_support
lunny/dm_ci
lunny/exec_driver_valuer
lunny/exec_support_conversion
lunny/fix_859
lunny/fix_oracle_time
lunny/green_plum
lunny/improve_read_preformance
lunny/json_with_texts
lunny/load
lunny/more_test
lunny/oracle_ora
lunny/redis_cache_test
lunny/return_error
lunny/slight_improvement_2
lunny/test_oracle2
lunny/test_postgres_index
lunny/upgrade_cockroach_test_env
master
patch
yuanfan/bugfix
godror
v.0.7.3
v0.0.1
v0.2
v0.2.1
v0.2.2
v0.2.3
v0.3.1
v0.3.2
v0.4.1
v0.4.2
v0.4.3
v0.4.4
v0.4.5
v0.5.0
v0.5.1
v0.5.2
v0.5.3
v0.5.4
v0.5.6
v0.5.7
v0.5.8
v0.6.0
v0.6.1
v0.6.2
v0.6.3
v0.6.4
v0.6.5
v0.6.6
v0.7.0
v0.7.1
v0.7.2
v0.7.3
v0.7.3.1
v0.7.4
v0.7.5
v0.7.6
v0.7.7
v0.7.8
v0.7.9
v0.8.0
v0.8.1
v0.8.2
v1.0.0
v1.0.1
v1.0.2
v1.0.2-godror
v1.0.2-godror-v2
v1.0.3
v1.0.3-godror
v1.0.3-oracle
v1.0.4
v1.0.5
v1.0.6
v1.0.7
v1.1.0
v1.1.1
v1.1.2
v1.2.0
v1.2.1
v1.2.2
v1.2.3
v1.2.4
v1.2.5
v1.3.0
v1.3.1
Labels
Apply labels
Clear labels
blocked
db/oracle
db/sqlserver
duplicate
feature/cache
invalid
kind/breaking
kind/bug
kind/build
kind/dependencies
kind/docs
kind/driver
kind/enhancement
kind/feature
kind/performance
kind/proposal
kind/proposal:accepted
kind/question
kind/refactor
kind/regression
kind/testing
kind/upstream
need/feedback
need/test
RaspBerry Pi
skip-changelog
wip
wontfix
No Label
blocked
db/oracle
db/sqlserver
duplicate
feature/cache
invalid
kind/breaking
kind/bug
kind/build
kind/dependencies
kind/docs
kind/driver
kind/enhancement
kind/feature
kind/performance
kind/proposal
kind/proposal:accepted
kind/question
kind/refactor
kind/regression
kind/testing
kind/upstream
need/feedback
need/test
RaspBerry Pi
skip-changelog
wip
wontfix
Milestone
Set milestone
Clear milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
Assign users
Clear assignees
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/xorm#2009
Reference in new issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
No
Yes
我目前的需求是把任意的mysql查询结果导出为csv文件(带字段名),期望达到的是,当用户在浏览器输入框输入任意sql语句时,将sql结果导出为csv供用户下载,例子如下
但现在用xorm好像不太好处理,因为engine.QueryInterface返回的结果格式是
[]map[string]interface{}
,而map是乱序的,这也导致了我无法按序提取出字段名我看了一下xorm库提供的接口,目前尚未找到较方便的做法来实现按序提取出字段名,请问可以提供支持吗?或者我怎么才能做到这点?
简要的来说,下方的[1].写法无法满足需求,期望的是[2].写法,怎么才能实现?
[1]. 现有的查询方式如下:
[2]. 期望的查询方式如下: