diff --git a/modelgen/table.go b/modelgen/table.go index 2c0b301e..a7cc1854 100644 --- a/modelgen/table.go +++ b/modelgen/table.go @@ -246,6 +246,9 @@ type {{ index . "StructName" }} struct { {{ end }} {{ template "extraFields" . }} } +func (a *{{ index . "StructName" }}) Table() string { + return {{ index . "StructName" }}Table +} {{ template "postStructDefinitions" . }} {{ template "extraDefinitions" . }} {{ template "extendedGen" . }} diff --git a/modelgen/table_test.go b/modelgen/table_test.go index 6d4e2711..b3e38111 100644 --- a/modelgen/table_test.go +++ b/modelgen/table_test.go @@ -80,6 +80,10 @@ type AtomicTable struct { Protocol *AtomicTableProtocol ` + "`" + `ovsdb:"protocol"` + "`" + ` Str string ` + "`" + `ovsdb:"str"` + "`" + ` } + +func (a *AtomicTable) Table() string { + return AtomicTableTable +} `, }, { @@ -103,6 +107,10 @@ type AtomicTable struct { Protocol *string ` + "`" + `ovsdb:"protocol"` + "`" + ` Str string ` + "`" + `ovsdb:"str"` + "`" + ` } + +func (a *AtomicTable) Table() string { + return AtomicTableTable +} `, }, { @@ -151,6 +159,10 @@ type AtomicTable struct { OtherProtocol *string OtherStr string } + +func (a *AtomicTable) Table() string { + return AtomicTableTable +} `, }, { @@ -189,6 +201,10 @@ type AtomicTable struct { Str string ` + "`" + `ovsdb:"str"` + "`" + ` } +func (a *AtomicTable) Table() string { + return AtomicTableTable +} + func (a *AtomicTable) GetUUID() string { return a.UUID } @@ -354,6 +370,10 @@ type AtomicTable struct { OtherStr string } +func (a *AtomicTable) Table() string { + return AtomicTableTable +} + func copyAtomicTableOtherProtocol(a *AtomicTableProtocol) *AtomicTableProtocol { if a == nil { return nil @@ -483,6 +503,10 @@ type AtomicTable struct { Str string ` + "`" + `ovsdb:"str"` + "`" + ` } +func (a *AtomicTable) Table() string { + return AtomicTableTable +} + func (a *AtomicTable) GetUUID() string { return a.UUID } @@ -606,6 +630,10 @@ type AtomicTable struct { Str string ` + "`" + `ovsdb:"str"` + "`" + ` } +func (a *AtomicTable) Table() string { + return AtomicTableTable +} + func TestFunc() string { return "AtomicTable" } diff --git a/ovsdb/serverdb/database.go b/ovsdb/serverdb/database.go index 274a7164..8d6f4ad7 100644 --- a/ovsdb/serverdb/database.go +++ b/ovsdb/serverdb/database.go @@ -30,6 +30,10 @@ type Database struct { Sid *string `ovsdb:"sid"` } +func (a *Database) Table() string { + return DatabaseTable +} + func (a *Database) GetUUID() string { return a.UUID }