Skip to content

Commit

Permalink
Merge pull request #124 from sjhewitt/sjh-postgres-views
Browse files Browse the repository at this point in the history
ignore views/foreign tables/temporary tables in postgres databases
  • Loading branch information
vgarvardt authored Sep 25, 2020
2 parents 602add2 + 954ae68 commit d726dda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions fixtures/pg_simple.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ CREATE TABLE "order_items" (
FOREIGN KEY (order_id) REFERENCES orders(id)
);


CREATE VIEW "users_view" AS SELECT id, username FROM "users" WHERE active=true;

INSERT INTO "users" VALUES ('0d60a85e-0b90-4482-a14c-108aea2557aa', 'wbo', '[email protected]', true, 'm', '2017-01-01');
INSERT INTO "users" VALUES ('39240e9f-ae09-4e95-9fd0-a712035c8ad7', 'kp', '[email protected]', true, NULL, '2017-01-01');
INSERT INTO "users" VALUES ('9e4de779-d6a0-44bc-a531-20cdb97178d2', 'lp', '[email protected]', false, 'f', '2017-01-01');
Expand Down
4 changes: 3 additions & 1 deletion pkg/reader/postgres/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ func (s *storage) GetTables() ([]string, error) {
log.Debug("fetching table list")
rows, err := s.conn.Query(
`SELECT table_name FROM information_schema.tables
WHERE table_catalog=current_database() AND table_schema NOT IN ('pg_catalog', 'information_schema')`,
WHERE table_catalog=current_database()
AND table_type = 'BASE TABLE'
AND table_schema NOT IN ('pg_catalog', 'information_schema')`,
)
if err != nil {
return nil, err
Expand Down

0 comments on commit d726dda

Please sign in to comment.