On 2/25/18 2:59 AM, Nick Sabalausky (Abscissa) wrote:
On 02/25/2018 02:01 AM, Suliman wrote:
What about string interpolation like:

conn.exec("INSERT INTO table_name VALUES ({i}, {s})"); ?

Instead of:
conn.exec("INSERT INTO table_name VALUES (?, ?)", i, s);

The syntax is purely, 100% server-side. Mysql-native just passes the whole string, question marks and all, straight off to the server. So whatever syntax the server supports, mysql-native supports. Whatever the server doesn't, mysql-native doesn't.

I've heard about a MySQL (I think) syntax like this:
"INSERT INTO table_name VALUES (:i, :s)"

But I haven't given it a try, and I don't know about its compatability.

I've been thinking about something more like this:

conn.exec("INSERT INTO table_name VALUES (", i, s, ")");

What I like about this, is that a real SQL insert can have lots of fields. Getting them all straight can be a pain in the ass, especially if you are inserting a couple somewhere.

But if the SQL library rearranges this for us, so we can put the data where it should be, it would be much nicer.

The one wrinkle that makes this difficult is strings that should be parameters. Are they parameters or SQL statement? I suppose you could wrap the statement strings into something, or the string values into something.

String interpolation would be really useful here. e.g.: https://forum.dlang.org/post/odb9hk$2jqm$1...@digitalmars.com

-Steve

Reply via email to