From 308845d7c04dbf49058973e810689da7bdf61a25 Mon Sep 17 00:00:00 2001 From: amirrezaask Date: Fri, 18 Mar 2022 02:52:19 +0330 Subject: [PATCH] small comment for my self future --- connection.go | 9 +++++++++ orm.go | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/connection.go b/connection.go index 187d2e8..5f480d6 100644 --- a/connection.go +++ b/connection.go @@ -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 { diff --git a/orm.go b/orm.go index 9cf831e..cd7a19c 100644 --- a/orm.go +++ b/orm.go @@ -86,6 +86,13 @@ func Setup(configs ...ConnectionConfig) error { } } + if conn.ValidateTablesSchemas { + err = conn.validateTablesSchemas() + if err != nil { + return err + } + } + } return nil