simple-module-core 0.0.46__tar.gz → 0.0.47__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.
Files changed (141) hide show
  1. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/PKG-INFO +1 -1
  2. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/pyproject.toml +1 -1
  3. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/__main__.py +2 -0
  4. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_expression_index.py +42 -3
  5. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_runner.py +7 -2
  6. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_expression_index_diagnostics.py +41 -0
  7. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/.gitignore +0 -0
  8. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/LICENSE +0 -0
  9. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/README.md +0 -0
  10. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/__init__.py +0 -0
  11. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/_data_doctor.py +0 -0
  12. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/_entry_point_errors.py +0 -0
  13. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/_i18n_flatten.py +0 -0
  14. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/_i18n_translator.py +0 -0
  15. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/_migration_doctor.py +0 -0
  16. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/_permission_grants.py +0 -0
  17. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/_request_hooks.py +0 -0
  18. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/activity_feed.py +0 -0
  19. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/app_state.py +0 -0
  20. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/audit_links.py +0 -0
  21. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/body_limits.py +0 -0
  22. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/correlation.py +0 -0
  23. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/cors.py +0 -0
  24. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/csp.py +0 -0
  25. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/data_compatibility.py +0 -0
  26. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/datetimes.py +0 -0
  27. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/deprecation.py +0 -0
  28. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/design_packs.py +0 -0
  29. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/__init__.py +0 -0
  30. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_coupling.py +0 -0
  31. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_css.py +0 -0
  32. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_db_extensions.py +0 -0
  33. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_dependencies.py +0 -0
  34. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_durable_names.py +0 -0
  35. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_heavy_task_imports.py +0 -0
  36. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_i18n.py +0 -0
  37. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_inertia_api.py +0 -0
  38. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_js_workspace.py +0 -0
  39. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_migration.py +0 -0
  40. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_module.py +0 -0
  41. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_pages.py +0 -0
  42. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_spa_mount.py +0 -0
  43. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_tenancy.py +0 -0
  44. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/diagnostics/_types.py +0 -0
  45. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/discovery.py +0 -0
  46. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/dotenv.py +0 -0
  47. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/durable_events.py +0 -0
  48. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/environments.py +0 -0
  49. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/events.py +0 -0
  50. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/exceptions.py +0 -0
  51. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/feature_flags.py +0 -0
  52. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/health.py +0 -0
  53. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/i18n.py +0 -0
  54. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/i18n_overrides.py +0 -0
  55. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/invalidation.py +0 -0
  56. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/invalidation_refresh.py +0 -0
  57. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/leases.py +0 -0
  58. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/mail.py +0 -0
  59. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/menu.py +0 -0
  60. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/module.py +0 -0
  61. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/module_meta.py +0 -0
  62. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/module_settings.py +0 -0
  63. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/path_rules.py +0 -0
  64. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/permission_denied.py +0 -0
  65. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/permissions.py +0 -0
  66. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/public_routes.py +0 -0
  67. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/py.typed +0 -0
  68. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/rate_limit.py +0 -0
  69. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/redirect_safety.py +0 -0
  70. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/resources.py +0 -0
  71. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/secret_fields.py +0 -0
  72. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/services.py +0 -0
  73. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/settings_base.py +0 -0
  74. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/settings_hydrate.py +0 -0
  75. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/setup_steps.py +0 -0
  76. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/singleflight.py +0 -0
  77. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/spa_mount.py +0 -0
  78. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/stored_settings.py +0 -0
  79. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/tenancy.py +0 -0
  80. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/tenant_events.py +0 -0
  81. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/user_directory.py +0 -0
  82. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/user_events.py +0 -0
  83. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/simple_module_core/versioning.py +0 -0
  84. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_audit_links.py +0 -0
  85. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_auth_provider_selection.py +0 -0
  86. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_core_app_state.py +0 -0
  87. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_core_data_compatibility_doctor.py +0 -0
  88. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_core_datetimes.py +0 -0
  89. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_core_discovery_stale_sys_path.py +0 -0
  90. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_core_inline_delivery_context.py +0 -0
  91. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_core_invalidation_refresh.py +0 -0
  92. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_core_leases.py +0 -0
  93. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_core_lifecycle_docs.py +0 -0
  94. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_core_mail_resolution.py +0 -0
  95. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_core_module_settings.py +0 -0
  96. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_core_settings_source_cache.py +0 -0
  97. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_core_singleflight.py +0 -0
  98. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_core_user_directory.py +0 -0
  99. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_csp_registry.py +0 -0
  100. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_css_diagnostics.py +0 -0
  101. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_css_scanner.py +0 -0
  102. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_db_extensions_diagnostics.py +0 -0
  103. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_deprecation_helper.py +0 -0
  104. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_design_packs.py +0 -0
  105. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_diagnostics.py +0 -0
  106. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_diagnostics_tenancy.py +0 -0
  107. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_discovery.py +0 -0
  108. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_discovery_missing_deps.py +0 -0
  109. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_doctor_cli_overrides.py +0 -0
  110. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_dotenv.py +0 -0
  111. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_durable_events.py +0 -0
  112. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_environments.py +0 -0
  113. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_events.py +0 -0
  114. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_events_inline.py +0 -0
  115. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_feature_flags.py +0 -0
  116. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_feature_flags_decorator.py +0 -0
  117. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_health_registry.py +0 -0
  118. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_heavy_task_imports_diagnostics.py +0 -0
  119. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_i18n.py +0 -0
  120. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_i18n_diagnostics.py +0 -0
  121. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_i18n_overrides.py +0 -0
  122. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_invalidation.py +0 -0
  123. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_invalidation_handlers.py +0 -0
  124. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_menu.py +0 -0
  125. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_module_base.py +0 -0
  126. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_module_diagnostics.py +0 -0
  127. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_path_rule_registries.py +0 -0
  128. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_permission_sources.py +0 -0
  129. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_permissions.py +0 -0
  130. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_permissions_admin_principal.py +0 -0
  131. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_public_routes.py +0 -0
  132. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_public_routes_rate_precedence.py +0 -0
  133. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_redirect_safety.py +0 -0
  134. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_services.py +0 -0
  135. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_settings_base.py +0 -0
  136. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_sm003_page_render.py +0 -0
  137. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_sm009_dynamic_coupling.py +0 -0
  138. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_sm034_durable_names.py +0 -0
  139. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_tenant_exists.py +0 -0
  140. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_tenant_roles.py +0 -0
  141. {simple_module_core-0.0.46 → simple_module_core-0.0.47}/tests/test_versioning.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: simple_module_core
3
- Version: 0.0.46
3
+ Version: 0.0.47
4
4
  Summary: Module-system primitives for the simple_module framework — ModuleBase, discovery, diagnostics, events
5
5
  Project-URL: Homepage, https://github.com/antosubash/simple_module_python
6
6
  Project-URL: Repository, https://github.com/antosubash/simple_module_python
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "simple_module_core"
3
- version = "0.0.46"
3
+ version = "0.0.47"
4
4
  description = "Module-system primitives for the simple_module framework — ModuleBase, discovery, diagnostics, events"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -33,6 +33,7 @@ from simple_module_core.diagnostics import (
33
33
  run_diagnostics,
34
34
  )
35
35
  from simple_module_core.diagnostics._dependencies import CODE as MISSING_DEPENDENCY_CODE
36
+ from simple_module_core.diagnostics._expression_index import sqlite_file_index_names
36
37
  from simple_module_core.diagnostics._i18n import unknown_overrides_for
37
38
  from simple_module_core.discovery import (
38
39
  discover_modules,
@@ -194,6 +195,7 @@ def main() -> int:
194
195
  i18n_extra_sources=extra,
195
196
  i18n_unknown_overrides=unknown_overrides,
196
197
  database_dialect=_database_dialect(),
198
+ existing_index_names=sqlite_file_index_names(_database_url()),
197
199
  )
198
200
  diagnostics.extend(override_findings)
199
201
  diagnostics.extend(migration_diagnostics(modules, _database_url(), find_env_file().parent))
@@ -4,7 +4,8 @@ SQLAlchemy cannot reflect expression indexes (``lower(email)``) on SQLite, so
4
4
  autogenerate and ``alembic check`` silently skip them there and report a clean
5
5
  diff. That is "unverified", not "clean": on Postgres the same index is either
6
6
  missing from the history or drifted. SM026 says so whenever the configured
7
- database is SQLite and any module model declares such an index.
7
+ database is SQLite and a module model declares such an index the database
8
+ does not have by name.
8
9
 
9
10
  Duck-typed on SQLAlchemy ``Table``/``Index`` objects (core does not depend on
10
11
  SQLAlchemy).
@@ -15,7 +16,9 @@ from __future__ import annotations
15
16
  import importlib
16
17
  import logging
17
18
  import re
19
+ import sqlite3
18
20
  from collections.abc import Iterable
21
+ from contextlib import closing
19
22
  from pathlib import Path
20
23
  from typing import TYPE_CHECKING, Any
21
24
 
@@ -122,13 +125,48 @@ def expression_index_advice(root: Path | None = None) -> str:
122
125
  )
123
126
 
124
127
 
128
+ def sqlite_file_index_names(database_url: str) -> frozenset[str] | None:
129
+ """Every index name in the SQLite file ``database_url`` names, or ``None``.
130
+
131
+ SQLite records an expression index's name even though SQLAlchemy cannot
132
+ reflect its definition. ``None`` when that cannot be read: another
133
+ database, an in-memory or URI-mode path, or a file that is missing (it is
134
+ opened read-only, so it is never created) or unreadable.
135
+ """
136
+ if not database_url.startswith("sqlite"):
137
+ return None
138
+ _, sep, rest = database_url.partition(":///")
139
+ path = rest.partition("?")[0]
140
+ if not sep or not path or path.startswith((":memory:", "file:")) or not Path(path).is_file():
141
+ return None
142
+ try:
143
+ uri = f"{Path(path).resolve().as_uri()}?mode=ro"
144
+ with closing(sqlite3.connect(uri, uri=True)) as conn:
145
+ rows = conn.execute("SELECT name FROM sqlite_master WHERE type = 'index'").fetchall()
146
+ except sqlite3.Error:
147
+ return None
148
+ return frozenset(row[0] for row in rows)
149
+
150
+
125
151
  def check_expression_indexes_unverifiable(
126
- tables: Iterable[Any], dialect: str | None, module_name: str
152
+ tables: Iterable[Any],
153
+ dialect: str | None,
154
+ module_name: str,
155
+ *,
156
+ existing_index_names: frozenset[str] | None = None,
127
157
  ) -> list[Diagnostic]:
128
- """SM026: INFO on SQLite when the models declare indexes it cannot verify."""
158
+ """SM026: INFO on SQLite when the models declare indexes it cannot verify.
159
+
160
+ ``existing_index_names`` (from :func:`sqlite_file_index_names`) drops the
161
+ indexes the database already has by name, as the revision hook does, so a
162
+ migrated app hears only about the ones it lacks (GH #933). ``None`` reports
163
+ them all.
164
+ """
129
165
  if dialect != "sqlite":
130
166
  return []
131
167
  found = find_expression_indexes(tables)
168
+ if existing_index_names is not None:
169
+ found = [(table, index) for table, index in found if index not in existing_index_names]
132
170
  if not found:
133
171
  return []
134
172
  names = ", ".join(f"{idx} ({tbl})" for tbl, idx in found)
@@ -153,5 +191,6 @@ __all__ = [
153
191
  "find_expression_indexes",
154
192
  "index_is_expression_based",
155
193
  "module_all_tables",
194
+ "sqlite_file_index_names",
156
195
  "unwrap_ordering",
157
196
  ]
@@ -33,6 +33,7 @@ def run_diagnostics(
33
33
  i18n_extra_sources: list[tuple[str, str, Path]] | None = None,
34
34
  database_dialect: str | None = None,
35
35
  i18n_unknown_overrides: dict[str, list[str]] | None = None,
36
+ existing_index_names: frozenset[str] | None = None,
36
37
  ) -> list[Diagnostic]:
37
38
  """Convenience function to run all diagnostics.
38
39
 
@@ -44,7 +45,8 @@ def run_diagnostics(
44
45
  host/ui locale dirs that aren't owned by a ``ModuleBase``.
45
46
  ``database_dialect`` (``"sqlite"``, ``"postgresql"``...) enables SM026, which
46
47
  flags expression indexes a SQLite database cannot verify, and SM029, which flags
47
- modules declaring ``db_extensions`` on SQLite.
48
+ modules declaring ``db_extensions`` on SQLite. ``existing_index_names``
49
+ (``sqlite_file_index_names``) limits SM026 to indexes the database lacks.
48
50
  ``i18n_unknown_overrides`` (``I18nRegistry.unknown_override_keys``) enables SM027.
49
51
  """
50
52
  diagnostics = ModuleDiagnostics().run(modules)
@@ -53,7 +55,10 @@ def run_diagnostics(
53
55
  for mod in modules:
54
56
  diagnostics.extend(
55
57
  check_expression_indexes_unverifiable(
56
- module_all_tables(mod), database_dialect, mod.meta.name
58
+ module_all_tables(mod),
59
+ database_dialect,
60
+ mod.meta.name,
61
+ existing_index_names=existing_index_names,
57
62
  )
58
63
  )
59
64
  diagnostics.extend(check_db_extensions_need_postgres(mod, database_dialect))
@@ -120,3 +120,44 @@ def test_text_ordering_and_literal_columns_still_count_as_expressions():
120
120
  ("t", "ix_t_literal"),
121
121
  ("t", "ix_t_text"),
122
122
  ]
123
+
124
+
125
+ def test_sm026_skips_indexes_the_database_already_has():
126
+ """GH #933: a migrated fresh app has the index; SM026 has nothing to say."""
127
+ assert (
128
+ check_expression_indexes_unverifiable(
129
+ _tables(),
130
+ "sqlite",
131
+ "Users",
132
+ existing_index_names=frozenset({"ix_users_user_email_lower"}),
133
+ )
134
+ == []
135
+ )
136
+ missing = check_expression_indexes_unverifiable(
137
+ _tables(), "sqlite", "Users", existing_index_names=frozenset()
138
+ )
139
+ assert [d.code for d in missing] == ["SM026"]
140
+
141
+
142
+ def test_sqlite_file_index_names_reads_the_file(tmp_path):
143
+ from simple_module_core.diagnostics._expression_index import sqlite_file_index_names
144
+
145
+ db = tmp_path / "app.db"
146
+ engine = sa.create_engine(f"sqlite:///{db}")
147
+ with engine.begin() as conn:
148
+ _tables()[0].metadata.create_all(conn)
149
+ engine.dispose()
150
+
151
+ names = sqlite_file_index_names(f"sqlite+aiosqlite:///{db}")
152
+ assert names is not None
153
+ assert "ix_users_user_email_lower" in names
154
+
155
+
156
+ def test_sqlite_file_index_names_is_none_when_it_cannot_tell(tmp_path):
157
+ from simple_module_core.diagnostics._expression_index import sqlite_file_index_names
158
+
159
+ missing = tmp_path / "missing.db"
160
+ assert sqlite_file_index_names(f"sqlite+aiosqlite:///{missing}") is None
161
+ assert not missing.exists() # read-only: never creates the file
162
+ assert sqlite_file_index_names("sqlite+aiosqlite:///:memory:") is None
163
+ assert sqlite_file_index_names("postgresql+asyncpg://u@h/db") is None