tableExist checks if a table exists in the database and current schema.
(ctx context.Context, conn dialect.ExecQuerier, name string)
| 60 | |
| 61 | // tableExist checks if a table exists in the database and current schema. |
| 62 | func (d *Postgres) tableExist(ctx context.Context, conn dialect.ExecQuerier, name string) (bool, error) { |
| 63 | query, args := sql.Dialect(dialect.Postgres). |
| 64 | Select(sql.Count("*")).From(sql.Table("tables").Schema("information_schema")). |
| 65 | Where(sql.And( |
| 66 | d.matchSchema(), |
| 67 | sql.EQ("table_name", name), |
| 68 | )).Query() |
| 69 | return exist(ctx, conn, query, args...) |
| 70 | } |
| 71 | |
| 72 | // matchSchema returns the predicate for matching table schema. |
| 73 | func (d *Postgres) matchSchema(columns ...string) *sql.Predicate { |
nothing calls this directly
no test coverage detected