{
  "id": 10037006,
  "title": "Your Search Query Is a Program: Composing Role-Based SQL With the Strategy Pattern",
  "url": "https://urgent.news/2026/09/26/your-search-query-is-a-program-composing-role-based-sql-with-the",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-26T18:19:15.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/purbano/your-search-query-is-a-program-composing-role-based-sql-with-the-strategy-pattern-3o3a"
  },
  "original_language": "en",
  "account": "Every business application contains a screen displaying records with filter boxes and user permissions. The initial SQL query starts with a SELECT, followed by a WHERE clause based on the user's office. Filters are added progressively, culminating in roles with varying levels of data visibility. Eventually, the query becomes a lengthy, hard-to-manage method that nobody wants to work on. The key point is that this query was never just a string; it's application logic with a security boundary. Building it by appending text results in a testable and reviewable process, but it remains as code rather than text. The strategy pattern is employed twice: once to determine what a user can see and another to handle the user's request, neither of which constructs the entire query.",
  "summary": "Every business application has this screen somewhere: a table of records, filter boxes above it, and a user who may only see part of the data. The first query is a SELECT with a WHERE on the user's office. Filters arrive one at a time, then a role that sees two offices, then an auditor who sees everything once approved. Eventually the query is a two-hundred-line method nobody wants to touch. Our…",
  "key_points": [
    "Query starts as SELECT with WHERE clause based on user's office",
    "Strategy pattern used twice: once for user visibility, another for handling request",
    "Query becomes lengthy, hard-to-manage method before refactoring"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}