News for hackers. Stuff that matters.
Re:Ask HN: How do you test SQL? by MBCook on Tuesday January 31, 2023 @05:56PM (#34603554)
This is what we did at my last job. You can catch DB specific issues that a false implementation wouldn’t show and make sure all your code paths work as expected.

Every time new issues cropped up we would put new data in the test data designed to reproduce it. Every edge case we would run into.

It provided so much confidence because it would catch and trigger so many edge cases that testing with mocks or by hand would miss.

Edit: also, it’s great for test/dev environments. You don’t have to worry about losing important data or filling new environments with data. Just start with the full test data and you’re good to go. It’s got stuff for all the corner cases already. Something got screwed up? Blow it away and reload, it’s not precious.

Re:Ask HN: How do you test SQL? by jdc0589 on Tuesday January 31, 2023 @06:13PM (#34603730)
same here. every backend service with a sql datastore runs an real ephemeral db instance during CI, runs the normal migrations against it, and uses it for tests of the direct data access/persistence code. everything else in the service with a dependency on the data-access stuff gets a mocked version, but testing the actual data access code against a real datasource is non-negotiable IMO.
Re:Ask HN: How do you test SQL? by fatneckbeard on Tuesday January 31, 2023 @08:01PM (#34604844)
thats a huge amount of work and money.

at my company they just told us to stop reporting edge cases. much easier, much cheaper.

Re:Ask HN: How do you test SQL? by nicoburns on Tuesday January 31, 2023 @09:23PM (#34605532)
It’s not that much work
Re:Ask HN: How do you test SQL? by organsnyder on Wednesday February 01, 2023 @07:42AM (#34609665)
Especially in the long-run.
Re:Ask HN: How do you test SQL? by fatneckbeard on Wednesday February 01, 2023 @07:55PM (#34620547)
its a joke people im trying to humorize the bureaucratic existence that most of humanity lives under.
Re:Ask HN: How do you test SQL? by justinclift on Tuesday January 31, 2023 @09:26PM (#34605547)
Sounds like a place that's not really interested in solving customer needs. :(

Most places aren't like that, at least the ones I've seen. :)

Re:Ask HN: How do you test SQL? by fatneckbeard on Wednesday February 01, 2023 @07:55PM (#34620540)
im not saying its right im just saying thats how it is, apparently i shouldnt joke about that stuff because i was downvoted to minus three.

our website crashes when the user types a double space. their solution is to have us tell users to stop typing in double spaces. since it only happens a few times a month its not considered a high priority. (details have been edited to protect the innocent)

Re:Ask HN: How do you test SQL? by acheton on Wednesday February 01, 2023 @04:26AM (#34608289)
We did something similar, being a small company we used batch files (checked into source control) to run database migrations on the different platforms we supported. Most database platforms have command line tools, although you need to be careful as there can be subtle differences in behaviour between the command line tools & those running with a UI.