MCPcopy
hub / github.com/ent/ent / tableExist

Method tableExist

dialect/sql/schema/postgres.go:62–70  ·  view source on GitHub ↗

tableExist checks if a table exists in the database and current schema.

(ctx context.Context, conn dialect.ExecQuerier, name string)

Source from the content-addressed store, hash-verified

60
61// tableExist checks if a table exists in the database and current schema.
62func (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.
73func (d *Postgres) matchSchema(columns ...string) *sql.Predicate {

Callers

nothing calls this directly

Calls 12

matchSchemaMethod · 0.95
DialectFunction · 0.92
CountFunction · 0.92
TableFunction · 0.92
AndFunction · 0.92
EQFunction · 0.92
existFunction · 0.85
QueryMethod · 0.65
WhereMethod · 0.65
FromMethod · 0.45
SelectMethod · 0.45
SchemaMethod · 0.45

Tested by

no test coverage detected