News for hackers. Stuff that matters.
Re:Myth: Select * is Bad by mistercow on Sunday August 25, 2013 @03:41PM (#6273375)
It seems to me that in discussions of NoSQL vs relational databases, one of the main arguments that comes up regarding ease of design and maintenance is "you can just use an ORM". But I see major disadvantage after major disadvantage of using an ORM, and there seems to be some overlap with the disadvantages of NoSQL (by which I am primarily referring to document-oriented databases). I really can't tell, once you factor these disadvantages in, what comes out on top.
Re:Myth: Select * is Bad by bcoates on Sunday August 25, 2013 @04:38PM (#6273620)
The ORM I really want just takes my SQL and a connection to my database at compile or load time, and wires it up to the type system of the language I'm using. All the ones I've tried just seem to embrace the awfulness of the low-level database access APIs and are just trying to replace the good-enough DSL that is SQL with something worse.
Re:Myth: Select * is Bad by johnpmayer on Sunday August 25, 2013 @06:25PM (#6274008)
http://www.haskell.org/haskellwiki/MetaHDBC

Does exactly that. Runs your SQL against the database at compile time to get type information, which it injects into the program AST.

Re:Myth: Select * is Bad by tmcneal on Sunday August 25, 2013 @06:04PM (#6273917)
The closest I've seen an ORM come to this is Squeryl: http://squeryl.org
Re:Myth: Select * is Bad by oacgnol on Sunday August 25, 2013 @11:28PM (#6275034)
Which has been superseded by Slick (http://slick.typesafe.com/) and does exactly as the parent says.
Re:Myth: Select * is Bad by pdpi on Sunday August 25, 2013 @07:26PM (#6274221)
In that regard, while not actually an ORM per se, one of the best experiences I've ever had with SQL integration in a language was SAP's ABAP, where column types and data types are (almost?) the exact same thing.
Re:Myth: Select * is Bad by stonemetal on Sunday August 25, 2013 @10:59PM (#6274928)
If you are in C# land Dapper does a good job of letting you write SQL and handle the messy put result sets in to objects part of the equation.
Re:Myth: Select * is Bad by kingkilr on Sunday August 25, 2013 @06:54PM (#6274097)
It's 100% possible to use SQLAlchemy to do that in Python.
Re:Myth: Select * is Bad by VeejayRampay on Sunday August 25, 2013 @04:57PM (#6273693)
ORMs are just like databases really. There's a good way and there's a bad way.

It's not the ORM that causes problems, it's all about the mindset of thinking that you don't have to worry about anything because the ORM will have your back anyway. I use ActiveRecord in Rails every day and there's a lot of things it just does right. It abstracts certain things I wouldn't want to constantly have to worry about and gives me a fine-grained enough layer of control over the queries that I can actually get all the expressiveness and power I need from the records.

Like they say, don't throw the baby with the bath water my friend.

Re:Myth: Select * is Bad by nbouscal on Sunday August 25, 2013 @03:53PM (#6273416)
I don't think one is inherently superior to the other, it just depends on the data. If you have highly structured data for which integrity is mission-critical, you want to be using a RDBMS. If you have unstructured data for which throughput is mission-critical, you'll probably benefit from using a NoSQL system.
Re:Myth: Select * is Bad by andrewflnr on Sunday August 25, 2013 @04:16PM (#6273518)
I'm sure someone has tried, but has anyone done a good job on an ORM that actually lets you select which columns to load and only selects those?
Re:Myth: Select * is Bad by riffraff on Sunday August 25, 2013 @04:31PM (#6273583)
Don't most ORM allow that?

i.e. rails' ActiveRecord allows you to select columns easily in most cases:

    User.where(..) # all fields
    User.where(..).select(:name, :id) # only two of them
    joe.boards.select(:title)  # only one in join
    joe.boards.pluck(:title)   # only column value instead of full objects with one attribute set
Though I recall it's involved for #belongs_to relations.

You should also be able to setup the select as a default per-class, other than per query.

I suspect, I likely didn't understand your question, could you expand it?

Re:Myth: Select * is Bad by andrewflnr on Sunday August 25, 2013 @04:52PM (#6273675)
It's possible I'm just ignorant of the capabilities of most ORMs. My only real experience is with the Django ORM. AFAIK, if you select an object, it wants to make sure all the members of the object are populated.

My apologies if it was a dumb question. :)

Re:Myth: Select * is Bad by meric on Sunday August 25, 2013 @05:57PM (#6273891)
Re:Myth: Select * is Bad by byroot on Sunday August 25, 2013 @05:57PM (#6273888)
By default yes, but like most ORMs you can ask to populate only some members: https://docs.djangoproject.com/en/dev/ref/models/querysets/#...
Re:Myth: Select * is Bad by acdha on Sunday August 25, 2013 @04:52PM (#6273678)
Django offer a couple of options:

    .only(… field list…)
    .defer(… fields to fetch on demand…)
https://docs.djangoproject.com/en/dev/ref/models/querysets/#...
Re:Myth: Select * is Bad by fatalmind on Sunday August 25, 2013 @04:18PM (#6273534)
here you go: http://use-the-index-luke.com/sql/join/hash-join-partial-obj...

It's really a PIA.

Recently, I've learned about http://jooq.org/ — not having checked in detail yet, it might be easier there.

Re:Myth: Select * is Bad by aidos on Sunday August 25, 2013 @05:12PM (#6273746)
SQL alchemy - it does everything the right way.

http://www.sqlalchemy.org/

Re:Myth: Select * is Bad by barrydahlberg on Sunday August 25, 2013 @04:52PM (#6273676)
.NETs Entity Framework lets you do this using the fantastic LINQ syntax. Commonly you will say which objects to select, then give a projection into a new anonymous type with only the columns you want.
Re:Myth: Select * is Bad by wtetzner on Sunday August 25, 2013 @07:02PM (#6274131)
It would be much nicer to use if C# had structural typing for the anonymous types, so you could usefully return them.