flask-postgresql-audit 1.0.1__tar.gz → 1.0.3__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.
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/PKG-INFO +2 -2
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/__init__.py +1 -1
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/alembic/entities.py +1 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/core.py +7 -0
- flask_postgresql_audit-1.0.3/flask_postgresql_audit/templates/jsonb_subtract.sql +22 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/pyproject.toml +1 -1
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/tests/app.py +4 -1
- flask_postgresql_audit-1.0.1/flask_postgresql_audit/templates/jsonb_subtract.sql +0 -5
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/.gitignore +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/CHANGES.md +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/LICENSE +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/README.md +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/alembic/__init__.py +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/alembic/schema.py +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/alembic/setup.py +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/base.py +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/models.py +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/templates/audit_trigger_delete.sql +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/templates/audit_trigger_insert.sql +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/templates/audit_trigger_update.sql +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/templates/create_activity.sql +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/templates/create_schema.sql +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/templates/drop_schema.sql +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/templates/get_setting.sql +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/templates/row_audit_trigger.sql +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/templates/row_create_activity.sql +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/typing.py +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/utils.py +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/tests/__init__.py +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/tests/conftest.py +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/tests/migrations/README +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/tests/migrations/alembic.ini +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/tests/migrations/env.py +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/tests/migrations/script.py.mako +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/tests/test_defaults.py +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/tests/test_operators.py +0 -0
- {flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/tests/utils.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flask-postgresql_audit
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Versioning and auditing extension for PostgreSQL and SQLAlchemy.
|
|
5
5
|
Project-URL: Homepage, https://github.com/higamigu/flask-postgresql-audit
|
|
6
|
-
Author-email:
|
|
6
|
+
Author-email: Higamigu <higamigu@gmail.com>, Konsta Vesterinen <konsta@fastmonkeys.com>
|
|
7
7
|
License-Expression: BSD-2-Clause
|
|
8
8
|
License-File: LICENSE
|
|
9
9
|
Classifier: Environment :: Web Environment
|
{flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/core.py
RENAMED
|
@@ -103,6 +103,8 @@ class PostgreSQLAudit:
|
|
|
103
103
|
pg_audit_enabled: bool
|
|
104
104
|
pg_audit_entities: OrderedSet[ReplaceableEntity]
|
|
105
105
|
|
|
106
|
+
options: dict[str, t.Any]
|
|
107
|
+
|
|
106
108
|
def __init__(
|
|
107
109
|
self,
|
|
108
110
|
*,
|
|
@@ -110,6 +112,7 @@ class PostgreSQLAudit:
|
|
|
110
112
|
actor_id_getter: t.Callable[[], t.Any] = _default_actor_id,
|
|
111
113
|
client_address_getter: t.Callable[[], t.Any] = _default_client_addr,
|
|
112
114
|
schema_name: t.Optional[str] = None,
|
|
115
|
+
**kw,
|
|
113
116
|
):
|
|
114
117
|
self._actor_cls = actor_cls
|
|
115
118
|
self.schema_name = schema_name
|
|
@@ -117,11 +120,15 @@ class PostgreSQLAudit:
|
|
|
117
120
|
self.get_actor_id = actor_id_getter
|
|
118
121
|
self.get_client_addr = client_address_getter
|
|
119
122
|
|
|
123
|
+
self.options = kw
|
|
124
|
+
|
|
120
125
|
@property
|
|
121
126
|
def context(self):
|
|
122
127
|
ctx = dict(schema_name=self.schema_name or "public")
|
|
123
128
|
ctx["schema_prefix"] = f"{ctx['schema_name']}."
|
|
124
129
|
ctx["revoke_cmd"] = f"REVOKE ALL ON {ctx['schema_prefix']}activity FROM public;"
|
|
130
|
+
if "jsonb_subtract_verbose" in self.options:
|
|
131
|
+
ctx["jsonb_subtract_join_type"] = "FULL"
|
|
125
132
|
return ctx
|
|
126
133
|
|
|
127
134
|
@contextmanager
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
CREATE FUNCTION ${schema_prefix}jsonb_subtract(arg1 jsonb, arg2 jsonb) RETURNS jsonb AS $$
|
|
2
|
+
SELECT
|
|
3
|
+
COALESCE(
|
|
4
|
+
json_object_agg(
|
|
5
|
+
KEY,
|
|
6
|
+
CASE WHEN new_type = 'object' AND old_type = 'object'
|
|
7
|
+
THEN ${schema_prefix}jsonb_subtract(new_value, old_value)
|
|
8
|
+
ELSE new_value END
|
|
9
|
+
),
|
|
10
|
+
'{}'
|
|
11
|
+
)::jsonb
|
|
12
|
+
FROM (
|
|
13
|
+
SELECT KEY, VALUE AS new_value, jsonb_typeof(VALUE) AS new_type
|
|
14
|
+
FROM jsonb_each(arg1::jsonb)
|
|
15
|
+
) AS NEW
|
|
16
|
+
${jsonb_subtract_join_type} OUTER JOIN (
|
|
17
|
+
SELECT KEY, VALUE AS old_value, jsonb_typeof(VALUE) AS old_type
|
|
18
|
+
FROM jsonb_each(arg2::jsonb)
|
|
19
|
+
) AS OLD
|
|
20
|
+
USING (KEY)
|
|
21
|
+
WHERE new_value IS DISTINCT FROM old_value
|
|
22
|
+
$$ LANGUAGE SQL;
|
|
@@ -8,7 +8,7 @@ readme = "README.md"
|
|
|
8
8
|
license = "bsd-2-clause"
|
|
9
9
|
requires-python = ">=3.11"
|
|
10
10
|
authors = [
|
|
11
|
-
{ name = "
|
|
11
|
+
{ name = "Higamigu", email = "higamigu@gmail.com" },
|
|
12
12
|
{ name = "Konsta Vesterinen", email = "konsta@fastmonkeys.com" },
|
|
13
13
|
]
|
|
14
14
|
classifiers = [
|
|
@@ -14,8 +14,11 @@ class DefaultConfig:
|
|
|
14
14
|
DB_PASSWORD = os.environ.get("POSTGRESQL_AUDIT_TEST_PASSWORD", "")
|
|
15
15
|
DB_NAME = os.environ.get("POSTGRESQL_AUDIT_TEST_DB", "postgresql_audit_test")
|
|
16
16
|
|
|
17
|
+
# SQLALCHEMY_DATABASE_URI = (
|
|
18
|
+
# f"postgresql://{DB_USER}:{DB_PASSWORD}@localhost/{DB_NAME}"
|
|
19
|
+
# )
|
|
17
20
|
SQLALCHEMY_DATABASE_URI = (
|
|
18
|
-
|
|
21
|
+
"postgresql://postgres:postgres@localhost:5492/pg_audit_test"
|
|
19
22
|
)
|
|
20
23
|
SQLALCHEMY_ECHO = False
|
|
21
24
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/base.py
RENAMED
|
File without changes
|
{flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/models.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/typing.py
RENAMED
|
File without changes
|
{flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/flask_postgresql_audit/utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flask_postgresql_audit-1.0.1 → flask_postgresql_audit-1.0.3}/tests/migrations/script.py.mako
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|