go-gorm / go-gorm/sqlserver

Migrator().DropTable() ignoring schema from struct.TableName()

Open
#127 0 comments 0 reactions 1 assignee Claimed by @jinzhu View on GitHub
Dominant language
Go
Stars
66
Forks
52
PR merge metrics
No merged PRs in 30d

Description

`Migrator().DropTable( &item{})` is not working properly when implementing `item.TableName()` and returning a name containing a schema, e.g:

```
type item struct {
Name string
}

func (i *item)TableName() string {return "test.item"} // specify schema name as "test"
```
calling `db.Migrator().DropTable(&item{})` generates the following SQL statement:

```
DROP TABLE IF EXISTS "item"
```
the statement is not using the full table name, the "schema." part is missing.

What is the proper way to find the table name for a struct? - I have seen different methods throughout issues and code.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.