Well, back in the "olden days" in the late 90's, this was actually pretty common: ColdFusion allowed SQL statements to be embedded in the templates, and JSP had sql tags. IIRC, most people moved away from that model primarily for flexibility and maintainability: having SQL statements mixed in with the presentation led to a lot of code duplication and made putting a different front-end (say, a third party API) nearly…
Don’t we all just want to use SQL on the front end?
101–110 of 184 posts
Re: Don’t we all just want to use SQL on the front end?
#102Earlier quoted context omitted.
These are the types APIs that I CONSTANTLY have to tell our internal guys "Hey, don't do that!" I get WHY you'd want to be able to throw in any random filter/sort to get the exact datapoints you are after, but that's both really hard to scale and often ends up being highly coupled to the underlying datastore. I get it, requirements gathering and making a clean API is hard and time consuming. What's harder is not doin…
Yeah; reading this the only 'gain' I saw was "we don't have to define an API". But instead you get to try and ensure that raw SQL from the client is always safe. The former isn't THAT hard to do. The latter is extraordinarily hard. Get the former wrong and you fix it before it ever goes live. Get the latter wrong and you fix it only after you're massively pwned. This is just a bad tradeoff.
That's where I've often run into the problem. When someone wants to make a monolith into a more microservice thing the hard part of carving out monolith usages takes meetings with consumers. Devs don't want a bunch of meetings and requirements gathering and a lot (at least in my org... :( ) would rather just write something cool and throw their hands up and say "We don't know how you'd use this, so we made you the boss".
Re: Don’t we all just want to use SQL on the front end?
#103https://github.com/porsager/HashQL-todos-sample/blob/master/...
Re: Don’t we all just want to use SQL on the front end?
#104I've been on the data side for a long time and have always wanted to explore front end but the API mandate sure did make that learning curve difficult, but for good reason.
It would be ideal if someone could iterate the existing frameworks to step something like GraphQL to a full blown front to back SQL tool.
Anyone who says SQL perms are crap doesn't know what they're doing with perms. I agree something is going to have to eloquently add controls between front and back.
Very thoughtful piece.
Re: Don’t we all just want to use SQL on the front end?
#105As many SQL Injection issues (and various other injection forms, including Javascript) as we have with backend code, fuck no we don't want SQL being issued from the frontend. For one, permissions around SQL are already crap. It takes the smallest screwup to expose data in co-mingled databases. No need to make it even worse. For two, at least if the SQL is on the backend, a fix for an exponential query DDOSing your DB…
No, they aren’t. At least not Postgres, and AFAIK its true of every other major RDBMS, too.
Non-DB-specialists typical level of knowledge of DB permissions may be, but that’s a whole different problem.
Re: Don’t we all just want to use SQL on the front end?
#106There is PostgREST, which is just a thin wrapper REST api around a Postgres database: https://postgrest.org/en/stable/
Strangely enough, I hardly ever see anyone really use the Postgres security checks. Postgrest is pretty much the only use case I've ever heard of.
Re: Don’t we all just want to use SQL on the front end?
#107With HashQL there actually was an experimental implementation of this idea https://github.com/porsager/HashQL-todos-sample/blob/master/...
Re: Don’t we all just want to use SQL on the front end?
#108As many SQL Injection issues (and various other injection forms, including Javascript) as we have with backend code, fuck no we don't want SQL being issued from the frontend. For one, permissions around SQL are already crap. It takes the smallest screwup to expose data in co-mingled databases. No need to make it even worse. For two, at least if the SQL is on the backend, a fix for an exponential query DDOSing your DB…
Not to mention: - super hard to cache if any client can basically generate an infinite number of different queries. - which dialect of SQL ? If you change DB or upgrade version, do your ask all clients to change as well ? - how do you do query that involves several data sources ? Some response data come from redis + elastic search + postgres. That's why FB created graphql. That's also why it's so limited in scope, so…
No, you implement an exposed schema for each app (or possibly more granular) that consists of objects (mostly views, possibly sprocs) optimized for the planned access pattern of the app (or whatever client/component thr schema is for), including convenience views abstracting those things away to the extent appropriate for the use case. That’s been a widely known RDBMS best practice for decades.
Re: Don’t we all just want to use SQL on the front end?
#109As many SQL Injection issues (and various other injection forms, including Javascript) as we have with backend code, fuck no we don't want SQL being issued from the frontend. For one, permissions around SQL are already crap. It takes the smallest screwup to expose data in co-mingled databases. No need to make it even worse. For two, at least if the SQL is on the backend, a fix for an exponential query DDOSing your DB…
It seems that the typical software engineer doesn't give security a single thought.
The way I understood the article, the ideas is 'can we expose a safe subset of SQL or fix the security issues instead of continuing to build entirely new systems'
Re: Don’t we all just want to use SQL on the front end?
#110As many SQL Injection issues (and various other injection forms, including Javascript) as we have with backend code, fuck no we don't want SQL being issued from the frontend. For one, permissions around SQL are already crap. It takes the smallest screwup to expose data in co-mingled databases. No need to make it even worse. For two, at least if the SQL is on the backend, a fix for an exponential query DDOSing your DB…