I can't ensure 100% that a function does take care of all the cases, and I might indeed need to use something like the algebric data types if I really need to ensure correcntess, but I don't see how those techniques have any application with data retrieval specifically (bad sql commands will easily fail anyway), and they can also be difficult to use for some "data driven" parts of a program that might parse user input from somewhere and use it as a command, like with the order by key example I wrote above.
Yeah by fail anyway easily I mean that the bad sql commands that can be adequately checked by a static typing system will just crash right away by the dbms anyway and not propagate errors making bug discovery and fixes rather trivial. While the really hard to track errors will usually be logical and I can't see how static types in sql commands will help much in avoiding those.
And like I said how the fuck is this gonna work with queries that are data driven? Is Ur/WebR or whatever the fuck is called running type analysis inside database tables or json strings? Is it reading the user's mind preemptively? Is it running inside the fucking Matrix?
Compile time SQL sounds like the usual pointless useless laughable god damn dumbass fizzbuzz enterprise edition bullshit of the IT industry.
running type analysis inside database tables or json strings?
The type checker knows your database schema. If you want to change the schema, you recompile your application, which re-type-checks the code against the new schema.
The type checker doesn't really process SQL strings, that would be awful! Instead it processes SQL syntax trees.
Static query construction using syntax trees? Don't nearly all ORM frameworks (Enity, Nhibernate etc.) do this to some extent? I can't say it's that useful, in fact I am usualy trying to bypass it. It can even get very wrong when it's done "high level" (with lazy loaded object members instead of relational queries), for example you might get n+1 selects out of nowhere.
Don't nearly all ORM frameworks (En[t]ity, N[H]ibernate etc.) do this? I can't say it's that useful, in fact I am usualy trying to bypass it.
It isn't pleasant with just nominal record types, because it forces you to define a struct/class/whatever for each relation schema (column set) a query could possibly return, or even worse, just treat every row as an array of Objects, which you then need to downcast, whether the downcasts are manually written by you, or generated by some wizard. Structural record types and row polymorphism are what makes type-checking arbitrary queries a breeze in Ur/Web.
But that's not why I am trying to bypass it, it's because most generic code on data records should treat the column names as dynamic "keys" (and like I said if it's high level OO based you can get errors or significant performance degradation where you don't expect it)
I am not sure what that has to do with what I was saying. Some simple to describe cases of the above that I can remember were for loading ID, [text description] fields for comboboxes across entities, constructing filters, and loading some 1:n and m:n entities in some specific way across many cases of "parent" entities. The equivalent purely static code had a lot more repition.
edit: In fact it boggles the mind that after the above discussion you would tell me about "insufficient flexible schema" and link to an article about database normalization? Hello? What the fuck does this have to do with anything, are you on mind altering drugs? Did you have a stroke???
0
u/uututhrwa Jun 12 '16
I can't ensure 100% that a function does take care of all the cases, and I might indeed need to use something like the algebric data types if I really need to ensure correcntess, but I don't see how those techniques have any application with data retrieval specifically (bad sql commands will easily fail anyway), and they can also be difficult to use for some "data driven" parts of a program that might parse user input from somewhere and use it as a command, like with the order by key example I wrote above.