mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-22 18:25:47 +08:00
Fix Syncer.getKey()
This commit is contained in:
parent
ec0f457c7f
commit
814d3f749b
@ -230,25 +230,32 @@ func (syncer *Syncer) getTable() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (syncer *Syncer) getKey() string {
|
||||
key := "id"
|
||||
hasKey := false
|
||||
hasId := false
|
||||
func (syncer *Syncer) getKeyColumn() *TableColumn {
|
||||
var column *TableColumn
|
||||
for _, tableColumn := range syncer.TableColumns {
|
||||
if tableColumn.IsKey {
|
||||
hasKey = true
|
||||
key = tableColumn.Name
|
||||
column = tableColumn
|
||||
}
|
||||
}
|
||||
|
||||
if column == nil {
|
||||
for _, tableColumn := range syncer.TableColumns {
|
||||
if tableColumn.Name == "id" {
|
||||
hasId = true
|
||||
column = tableColumn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !hasKey && !hasId {
|
||||
key = syncer.TableColumns[0].Name
|
||||
if column == nil {
|
||||
column = syncer.TableColumns[0]
|
||||
}
|
||||
|
||||
return key
|
||||
return column
|
||||
}
|
||||
|
||||
func (syncer *Syncer) getKey() string {
|
||||
column := syncer.getKeyColumn()
|
||||
return util.CamelToSnakeCase(column.CasdoorName)
|
||||
}
|
||||
|
||||
func RunSyncer(syncer *Syncer) error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user