soda-postgres 4.28.0__tar.gz → 4.29.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soda-postgres
3
- Version: 4.28.0
3
+ Version: 4.29.0
4
4
  Summary: Soda Postgres V4
5
5
  Author-email: "Soda Data N.V." <info@soda.io>
6
6
  License: Proprietary
7
7
  Requires-Python: >=3.10
8
- Requires-Dist: soda-core==4.28.0
8
+ Requires-Dist: soda-core==4.29.0
9
9
  Requires-Dist: psycopg[binary]>=3.2
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "soda-postgres"
3
- version = "4.28.0"
3
+ version = "4.29.0"
4
4
  description = "Soda Postgres V4"
5
5
  requires-python = ">=3.10"
6
6
  license = {text = "Proprietary"}
@@ -8,7 +8,7 @@ authors = [
8
8
  {name = "Soda Data N.V.", email = "info@soda.io"}
9
9
  ]
10
10
  dependencies = [
11
- "soda-core==4.28.0",
11
+ "soda-core==4.29.0",
12
12
  "psycopg[binary]>=3.2",
13
13
  ]
14
14
 
@@ -231,6 +231,18 @@ class PostgresSqlDialect(SqlDialect, sqlglot_dialect="postgres"):
231
231
  def _current_database(self) -> str:
232
232
  return "current_database()"
233
233
 
234
+ def readable_relation_sql_condition(self) -> str:
235
+ # pg_catalog shows every role all names, so keep only what this role can SELECT * from, as scans do: a table
236
+ # grant, or a grant on every column. has_any_column_privilege hides a table with no columns and no grant, and
237
+ # NOT x.attisdropped skips dropped columns. Expects pg_class aliased as c and pg_namespace as n.
238
+ return """(has_schema_privilege(n.oid, 'USAGE')
239
+ AND (has_table_privilege(c.oid, 'SELECT')
240
+ OR (has_any_column_privilege(c.oid, 'SELECT')
241
+ AND NOT EXISTS (
242
+ SELECT 1 FROM pg_catalog.pg_attribute x
243
+ WHERE x.attrelid = c.oid AND x.attnum > 0 AND NOT x.attisdropped
244
+ AND NOT has_column_privilege(c.oid, x.attnum, 'SELECT')))))"""
245
+
234
246
  def relkind_table_type_sql_expression(self, table_alias: str = "c", column_alias: str = "table_type") -> str:
235
247
  return f"""CASE {table_alias}.relkind
236
248
  WHEN 'r' THEN
@@ -364,6 +376,8 @@ class PostgresSqlDialect(SqlDialect, sqlglot_dialect="postgres"):
364
376
  [LITERAL("r"), LITERAL("p"), LITERAL("v"), LITERAL("m"), LITERAL("f")],
365
377
  ),
366
378
  GT(COLUMN("attnum", "a"), LITERAL(0)),
379
+ # A table's columns show in full or not at all, same as the tables it is discovered with.
380
+ RAW_SQL(self.readable_relation_sql_condition()),
367
381
  ]
368
382
  if table_name:
369
383
  where_conditions.append(EQ(COLUMN("relname", "c"), LITERAL(self.metadata_casify(table_name))))
@@ -68,6 +68,7 @@ class PostgresMetadataTablesQuery(MetadataTablesQuery):
68
68
  ],
69
69
  )
70
70
  ),
71
+ WHERE(RAW_SQL(self.sql_dialect.readable_relation_sql_condition())),
71
72
  ]
72
73
 
73
74
  if database_name:
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: soda-postgres
3
- Version: 4.28.0
3
+ Version: 4.29.0
4
4
  Summary: Soda Postgres V4
5
5
  Author-email: "Soda Data N.V." <info@soda.io>
6
6
  License: Proprietary
7
7
  Requires-Python: >=3.10
8
- Requires-Dist: soda-core==4.28.0
8
+ Requires-Dist: soda-core==4.29.0
9
9
  Requires-Dist: psycopg[binary]>=3.2
@@ -1,2 +1,2 @@
1
- soda-core==4.28.0
1
+ soda-core==4.29.0
2
2
  psycopg[binary]>=3.2
File without changes