Skip to content

Commit

Permalink
small comment for my self future
Browse files Browse the repository at this point in the history
  • Loading branch information
amirrezaask committed Mar 17, 2022
1 parent 01b7aae commit 308845d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ func (c *connection) validateAllTablesArePresent() error {
return nil
}

func (c *connection) validateTablesSchemas() error {
// check for entity tables: there should not be any struct field that does not have a coresponding column

// check for relation tables: for HasMany,HasOne relations check if OWNER pk column is in PROPERTY,
// for BelongsToMany check intermediate table has 2 pk for two entities

return nil
}

func (c *connection) Schematic() {
fmt.Printf("SQL Dialect: %s\n", c.Dialect.DriverName)
for t, schema := range c.Schemas {
Expand Down
7 changes: 7 additions & 0 deletions orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ func Setup(configs ...ConnectionConfig) error {
}
}

if conn.ValidateTablesSchemas {
err = conn.validateTablesSchemas()
if err != nil {
return err
}
}

}

return nil
Expand Down

0 comments on commit 308845d

Please sign in to comment.