[OT] Idea to get all columns from multiple tables in DB

Jesse Phillips Jesse.K.Phillips+D at gmail.com
Wed Jan 8 02:28:57 UTC 2020


On Tuesday, 7 January 2020 at 21:01:46 UTC, Steven Schveighoffer 
wrote:

> connection.query("SELECT e.*, 'user_' as __prefix, u.* FROM 
> ...").byItem!(Equipment, DB.colPrefix!"user_", User)
>
> [...]
>
> Is this a technique that is used by anyone regularly? If so, 
> what is it called? I'm very excited about this, because I want 
> to minimize DB round trips, and also fetch related items as 
> they come in, instead of serializing all of one type to an 
> array and then fetching the rest with individual queries, but I 
> didn't want to type out a lot of SQL (or generate it based on 
> possibly stale struct field names), and have to maintain it any 
> time I change something. This solves all the problems in a neat 
> way.
>
> -Steve

I don't believe I've seen this pattern.

What I realized after watching your talk is that I've generally 
married the structure to the query rather then the tables or data.

Select user.name, equip.product...

struct Ownership {
    string usersname;
    string product;
}

I this situation the assignment comes from position and not by 
column name. You lose the * as you mentioned.

What I have not done is thought about how our application differ 
for dealing with the data.



More information about the Digitalmars-d mailing list