Urgent.News

What's breaking now, across thousands of outlets.

Tech

Beyond ORMs

For years, the author has been fascinated by the design of object-relational mappings (ORMs), exploring various options and even creating one of their own. However, over the past few years, the author has shifted towards working more directly with databases, utilizing plain SQL, processing raw data, and building custom low-level abstractions. This change in approach led to the creation of Extralite, a Ruby gem for working with SQLite databases.

Direct interaction with the database, the author contends, is superior to using an ORM. ORMs fall short in supporting advanced features such as window functions, common table expressions (CTEs), and the RETURNING clause. Additionally, ORMs introduce performance costs in terms of memory and CPU time, and their fundamental design of mapping rows to objects is considered an anti-pattern.

The author acknowledges the popularity and influence of ActiveRecord, the most widely used ORM in the Ruby/Rails community. However, the author believes ActiveRecord's abstraction of the single record is inadequate, particularly when dealing with normalized databases containing numerous tables with ancillary data that should not be treated as separate entities.

The author argues that ORM APIs, which are centered around the concept of a separate object for each row, can lead novice programmers to believe they are working with discrete objects rather than entries in a record set. This can result in inefficient patterns, such as issuing multiple queries to delete or update records. The author demonstrates how using a single query with the RETURNING clause in databases like PostgreSQL and SQLite can resolve this issue, returning both the deleted records and their content.

The author further emphasizes that the number of distinct queries required by most web applications is finite and relatively small, often limited to a dozen or fewer queries per table. Therefore, the author questions the necessity of ORMs and their accompanying DSLs, which offer hundreds of instance and class methods. In most cases, the amount of SQL written in an application is negligible compared to the Ruby code.

The author concludes that the advantages provided by ORMs, such as a convenient DSL and built-in features like associations, can be outweighed by the complexity and limitations they introduce when working with more advanced or esoteric database queries.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at noteflakes.com →

More in Tech

To Promote Grand Theft Auto 6, Mayor Might Transform Miami into 'Vice City'

Rockstar Games and the mayor of Miami-Dade county are discussing a joint marketing campaign transforming parts of the county to look like areas from Grand Theft Auto 6, reports the blog Rock Paper…

  • Mayor of Miami-Dade County exploring marketing push with Rockstar Games.
  • Initiative to transform parts of Miami into Vice City from Grand Theft Auto 6.
  • Components include airport experience, branded Metromover trains, and motor fest.

HMAC Proves Origin, Not Freshness: Replay Attacks Against Signed APIs

HMAC Proves Origin, Not Freshness: Replay Attacks Against Signed APIs The signature verified. The secret was correct. The payment processed for the fourth time, from a request captured three hours…

  • HMAC verifies request origin, not freshness
  • Signed APIs vulnerable to replay attacks
  • Timestamp inclusion prevents replay vulnerabilities

PKCE Downgrade Attack: When the Authorization Server Accepts Both Flows

Two CVEs against the same identity provider, filed six months apart. CVE-2023-48228 and CVE-2024-23647, both against authentik, describe the same failure: the server accepted PKCE in one request and…

  • CVE-2023-48228 vulnerability in authentik versions 2023.10.4 and 2023.8.5 allows PKCE downgrade.
  • CVE-2024-23647 vulnerability in authentik versions 2023.10.6 and 2023.8.6 permits PKCE bypass.

Stop Hand-Partitioning Disks: Practical systemd-repart on Linux

Stop Hand-Partitioning Disks: Practical systemd-repart on Linux You ship a minimal OS image. The target disk is 64 GB, 256 GB, or 2 TB. Root is still 8 GB. Swap does not exist.

  • systemd-repart simplifies disk partitioning for Linux OS images
  • Configurations defined in repart.d/.conf files, no fragile installer hooks
  • Incremental and idempotent tool, operates on GPT disks

More from Sunday 6 September →