MSSQL_DIALECT读取表格字段时,出现重复现象 #787
Labels
No Label
backport/done
backport/v1
blocked
db
oracle
db
sqlserver
duplicate
feature
cache
frontport/done
frontport/main
invalid
kind
breaking
kind
bug
kind
build
kind
dependencies
kind
docs
kind
driver
kind
enhancement
kind
feature
kind
performance
kind
proposal
kind
question
kind
refactor
kind
testing
need
feedback
need
test
proposal:accepted
RaspBerry Pi
regression
skip-changelog
upstream
wip
wontfix
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#787
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
在使用该功能的时候,出现字段重复的现象,仔细研究一下,发现好象sql文写的不对,缺少条件,以及判断的条件不正确,下面是我修改的,可能不正确,但出现正确结果。请仔细研究一下。
func (db *mssql) GetColumns(tableName string) ([]string, map[string]*core.Column, error) {
args := []interface{}{}
s :=
select a.name as name, b.name as ctype,a.max_length,a.precision,a.scale,a.is_nullable as nullable, replace(replace(isnull(c.text,''),'(',''),')','') as vdefault, case when ISNULL( ic.column_id, 0 ) >0 then 1 else 0 end from sys.columns a left join sys.types b on a.user_type_id=b.user_type_id left join sys.syscomments c on a.default_object_id=c.id left outer JOIN sys.indexes i ON i.object_id = a.object_id AND i.is_primary_key = 1 left outer join sys.index_columns ic on ic.object_id=a.object_id and ic.column_id=a.column_id and i.index_id=ic.index_id where a.object_id=object_id('
+ tableName +')
db.LogSQL(s, args)
........
还有一个问题,是自增列没有进行判断,即没有读取自增列的值,并赋给列结构
#1203 will implement set auto-increment column 's value to struct field when insert a record.
Fixed by #1225