Mandatory background checks are a terrible idea. They burden law-abiding citizens and don’t catch criminals. The databases they rely on are riddled with errors. We don’t even prosecute people who flunk the checks. That’s why Republicans are against imposing such checks on gun buyers.

On the other hand, if you want to catch illegal immigrants, forget everything I just said. Running everybody through a database is a terrific idea. Republicans are all for it.

How did the GOP end up in this position? The story begins a couple of years ago, when Sen. Charles Grassley, R-Iowa, introduced the Accountability Through Electronic Verification Act. Grassley explained that the bill would “require that all employers use the E-Verify program,” a “web-based tool that allows employers to verify the work eligibility of new employees,” thereby “combating the hiring of illegal aliens.” E-Verify would become “mandatory for all employers within one year.” Companies would have to “check the status of existing employees within 3 years” and “terminate the employment of those found unauthorized to work.”

Advocates of immigration control loved E-Verify. But libertarians hated it. They called it a “national identification and surveillance system” that would help the government “compile and monitor the personal information of every person seeking employment.” Instead of flagging illegals—a task at which the system failed more than half the time, according to one analysis—they predicted that mandatory checks would simply “increase the number of employers and workers who resort to the black market.”

They also protested that the system generated too many “false positives”—“people wrongly labeled as undocumented by the system and then forced to undergo additional paperwork and fees to clear their names.” These people would have to “visit federal offices” and wait to resolve their eligibility. Indeed, the E-Verify website has acknowledged that more than 98 percent of employees subjected to checks are perfectly legal. All in all, the opponents concluded, an E-Verify mandate would impose a “flawed, costly system on law-abiding citizens.”