Metastatic.Semantic.Domains.Database (Metastatic v0.10.4)

View Source

Database operation patterns for semantic enrichment.

This module defines patterns for detecting database operations across multiple languages and ORM frameworks. Patterns are registered with the Metastatic.Semantic.Patterns registry at module load time.

Supported Frameworks

Elixir

  • Ecto - Repo.* operations

Python

  • SQLAlchemy - session.*, query.* operations
  • Django ORM - *.objects.* operations
  • Peewee - Model class operations

Ruby

  • ActiveRecord - Model class and instance operations

JavaScript

  • Sequelize - Model class operations
  • TypeORM - Repository operations
  • Prisma - Client operations
  • Mongoose - Model operations

Pattern Structure

Each pattern is a tuple of {pattern, spec} where:

  • pattern - String or Regex to match function names
  • spec - Map with operation details:
    • :operation - The database operation type
    • :framework - The ORM framework identifier
    • :extract_target - Strategy for extracting entity name

Target Extraction

Three strategies for extracting the target entity:

  • :first_arg - First argument is the entity (e.g., Repo.get(User, 1))
  • :receiver - Receiver is the entity (e.g., User.find(1))
  • :none - No target extraction

Summary

Functions

Registers all database patterns for all languages.

Functions

register_all()

@spec register_all() :: :ok

Registers all database patterns for all languages.

Called automatically when the module is loaded. Can also be called manually to re-register patterns (e.g., after clearing).