Urgent.News

What's breaking now, across thousands of outlets.

Tech

Your SQLAlchemy test factory fails at random past 50 rows. Here's the one-line fix.

You write a test that seeds a hundred rows with a factory. It fails with IntegrityError: UNIQUE constraint failed: users.id . You run it again and it passes. You run it a third time and it fails. Nothing is wrong with your models. The factory is drawing primary keys out of a hat. I measured it with polyfactory 3.3.0 and SQLAlchemy 2.1.1, and the fix is one line. I maintain seedgraph , a library…

A test factory designed to create 100 rows of data using SQLAlchemy failed sporadically when the number of rows exceeded 50. The issue stemmed from the factory's default behavior of filling primary key columns with values generated by Faker's pyint(), which had a limited range of 0 to 9999. This limited range made it likely for duplicate values to appear, causing a UNIQUE constraint violation due to the UNIQUE constraint on the id field in the User model.

To resolve this issue, the code was modified by setting the __set_primary_key__ attribute of the PostFactory to False. By doing so, the factory left the primary keys empty, allowing the database to assign them. This change eliminated the intermittent failures and improved the reliability of the test.

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

Read the original at dev.to →

More in Tech

Waymo Says Its Self-Driving Cars Reduced Injury-Causing Accidents by 82%

Waymo's self-driving car technology "continues to outperform human benchmarks," the company claimed this week. "It was involved in 841 fewer injury-causing crashes — an 82% reduction compared to human…

  • Waymo's self-driving cars reduced injury-causing accidents by 82%
  • 841 fewer crashes resulted in injuries compared to human drivers
  • Significant decrease in accidents involving pedestrians, cyclists, and motorcyclists

Screenshot testing a design system with Playwright and Docker

I work on the Koobiq design system, which has component libraries for React and Angular . in this article I'll show how the screenshot tests in our React library are set up and which decisions made…

  • Koobiq design system includes React and Angular component libraries
  • Screenshots tests use Playwright on Storybook with pixel precision
  • Tests run in Docker, baselines stored in Git next to components

Road to Golden Jacket

More than four years after passing the AWS Cloud Practitioner, learning and earning AWS certifications along the way, I finally achieved the Golden Jacket!

  • AI Practitioner certification focuses on AI, Machine Learning, and Generative AI concepts within AWS
  • Golden Jacket awarded after earning various AWS certifications in a single year

160 browser-only tools later: the engineering decisions that actually mattered

My last post was the tour — the tools, the categories, why everything runs in your browser. This one is the sticky stuff: the decisions that cost me the most time, so you can skip them.

  • Engineering decisions include Next.js 14 App Router, TypeScript, and Tailwind
  • Site features 399 static pages in English and Turkish with bilingual approach
  • Registry consistency check ensures tool list, component map, and icon map synchronization

More from Sunday 27 September →