DEV Community

Discussion on: You Can Do it in SQL, Stop Writing Extra Code for it

Collapse
 
buinauskas profile image
Evaldas Buinauskas • Edited

Company I work for has exactly this issue. Literally all the logic (sometimes even presentational logic) is done in the database.

This is nightmare to maintain and now really difficult to refactor.

Also it's difficult to test SQL code due to lack of tools.

Collapse
 
geshan profile image
Geshan Manandhar

Probably as most of you agree it is a bad practice due to:

  • cannot track code in DVCS like git
  • cannot test DB code
  • a lot harder to scale

It is better to convenience the devs and mgmt to slowly move it out if possible.

Thread Thread
 
buinauskas profile image
Evaldas Buinauskas • Edited

First one is not true.

We successfully version database code using Git, have working pull requests, continuous integration and delivery.

Second is not true as well. For instance, T-SQL code can be tested using tSQLt framework. Yet again. This is more difficult and not a widely adopted practice, but it's possible and companies do it.

But in any case. Even though things are possible and can be done in database, it doesn't mean it should be.

Thread Thread
 
sdedalus profile image
David

Database testing is a nightmare I hope to never repeat. Just because a thing can be done do not mean that it should be done.

Thread Thread
 
divakarraj profile image
Divakar Rajashekaran

It's not true in anyway that DB code is hard to test. As long as the person is aware of DB based code units it's just the same.

Thread Thread
 
geshan profile image
Geshan Manandhar

Maybe you are right!