5 ms·
That's really a so bad practice, a big code smell.. how you test all the dB logic, with a different dB? Constraints, indexes, tsvs..
by jordic 6y ago
That's really a so bad practice, a big code smell.. how you test all the dB logic, with a different dB? Constraints, indexes, tsvs..
- VWWHFSfQ 6y ago> As long as your CI tests use your production database server type
- bb88 6y agoAnd give the dev the ability to switch out to a different database if needed. Thankfully, in Django it's just a config switch. But for 99% of the business logic tests I write, sqlite is fine. Sure you might have an issue with Oracle, but for day to day stuff, sqlite is good enough.
- jordic 6y agoThat's because you are not using the power of postgresql.. (if you can test and run locally with sqlite).. are you using transactions, no? Because Django doesn't enforce them O_O
- VWWHFSfQ 6y agoWhat do you mean Django doesn't enforce them? Are you saying that transaction.atomic doesn't actually run in an atomic transaction?
- jordic 6y agoNo I'm saying that if you mutate related models and didn't wrap them on a transaction it can leave you (if something fails) on an inconsistent dB state.. this is something it can't happen on sqla
- VWWHFSfQ 6y agoThen wrap the things that you want to run in a transaction.atomic. Is there something I'm missing?
- jordic 6y agoThat's the thing, you need to explicitly run on a transaction.atomic, with sqlalchemy, that's something that just works..
- bildung 6y agoWhich is reasonable with sqalchemy because it operates at a lower level, where you manually handle sessions anyway. You don't do that in Django, by design. You can change commit behaviour if you want, though, and then you can just use transaction.atomic and still don't handle the session manually. If you'd want atomic transactions for the whole Django project, you could just set the ATOMIC_REQUESTS flag in the settings.
- jordic 6y agoThat's a nice feature, when landed it?
- bildung 6y agoAt least in Django 1.6 from 2014, couldn't find older docs.
- jordic 6y agoDoes still django lacks a connection pooling? If I'm not wrong sometime ago I saw people using the sqlalchemy pool on Django projects.
- bildung 6y agoNot since Django 1.6 from 2014.
- sago 6y ago> That's because you are not using the power of postgresql... Isn't that a potential positive? I mean, yeah, and those darn programmers with their 'platform independent languages'. Why are you not using the power of assembly?
- djur 6y agoThe very best ORMs are not anywhere near as good at 'compiling' their abstractions into platform-specific SQL than your standard C/C++ compiler is at producing optimized platform-specific machine code. Part of the reason for this is that SQL is already at a high level of abstraction comparable to the ORMs themselves; the relationship between Python and SQL is not comparable to the relationship between Python and assembly (or C and assembly, etc.)
- marcus_holmes 6y agoNo, it's really not. A better analogy than the language one: Your web app has to run on Firefox, Chrome, and... IE6 yay! You're not allowed to use any modern Javascript, or most of the API's you'd like to use. Because being able to switch to IE6 at any point in development is more useful than any of those fancy-dancy API's, right?
- sago 6y agoMeh. All analogies are partial. If there was an ORM that dealt with everything but a flaky end of life database, sure start working on it. But this is advocating picking one platform. Like creating Chrome-only JavaScript. I guess the nearest thing with Electron. Yeah the analogies breakdown at some point. I don't think anything is black-and-white. I just think the vast majority of Django apps are fine with Django's ORM. This article smacked of premature optimisation.
- marcus_holmes 6y agoI always get the feeling that people love ORMs because they don't want to learn SQL. Because if you do learn some SQL, then the problems with ORMs become annoyingly apparent. I agree that most Django coders will be fine with the ORM. I guess I don't see that as a good thing, though.
- nikisweeting 6y agoWith CI that tests both, and a dev team that runs a mixture of both. Also Django abstracts the differences away well enough that we've never noticed meaningful differences that aren't already well documented.
- Hamuko 6y agoAre you talking about databases or decibels?
- jordic 6y agoHaha, dB = database. My android keyboard is trolling me :/