String Interpolation: SQL revisited: Dynamic Table Names

kdevel kdevel at vogtner.de
Fri Feb 23 23:47:47 UTC 2024


After the DIP 1036(e) discussions I am under the impression that 
with the upcoming dmd release one shall be entitled to instead

     auto result = db.rows ("select id, a from b where id = ?", 
id);

write

     auto result = db.rows (i"select id, a from b where id = $id");

But what shall be written if the table from which the data are 
selected is variable, too? E.g.

     string t = "ta-ble";
     :
     auto result
        = db.rows ("select id, a from `" ~ t ~ "` where id = ?", 
id);

What if the escaping rules for table names and data are 
different? Can query authors benefit from string interpolation in 
this case?


More information about the Digitalmars-d mailing list