mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +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 {
|
func (syncer *Syncer) getKeyColumn() *TableColumn {
|
||||||
key := "id"
|
var column *TableColumn
|
||||||
hasKey := false
|
|
||||||
hasId := false
|
|
||||||
for _, tableColumn := range syncer.TableColumns {
|
for _, tableColumn := range syncer.TableColumns {
|
||||||
if tableColumn.IsKey {
|
if tableColumn.IsKey {
|
||||||
hasKey = true
|
column = tableColumn
|
||||||
key = tableColumn.Name
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if column == nil {
|
||||||
|
for _, tableColumn := range syncer.TableColumns {
|
||||||
if tableColumn.Name == "id" {
|
if tableColumn.Name == "id" {
|
||||||
hasId = true
|
column = tableColumn
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !hasKey && !hasId {
|
if column == nil {
|
||||||
key = syncer.TableColumns[0].Name
|
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 {
|
func RunSyncer(syncer *Syncer) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user