Using the result of a comma expression is deprecated

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Nov 27 04:13:03 PST 2016


On Sunday, 27 November 2016 at 11:49:25 UTC, Suliman wrote:
> On Sunday, 27 November 2016 at 11:21:58 UTC, drug007 wrote:
>> On 27.11.2016 14:07, Suliman wrote:
>>> I am getting deprecation message:
>>> "Using the result of a comma expression is deprecated" on 
>>> this code:
>>>
>>> string sqlinsert = (`INSERT INTO usersshapes (userlogin, 
>>> uploading_date,
>>> geometry_type, data) VALUES ('%s', '%s', '%s', '%s') `, login,
>>> uploading_date, geometry_type, data);
>>>
>>> What's wrong with it?
>> Didn't you miss something like class/structure/function before 
>> "(`INSERT..."? What result do you expect?
>
> 	void dbInsert(string login, string uploading_date, string 
> geometry_type, string data)
> 	{
> 	
> 	    Statement stmt = conn.createStatement();
> 		string sqlinsert = (`INSERT INTO usersshapes (userlogin, 
> uploading_date, geometry_type, data) VALUES ('%s', '%s', '%s', 
> '%s') `, login, uploading_date, geometry_type, data);
> 		stmt.executeUpdate(sqlinsert);
> 		scope(exit) stmt.close(); // closing
> 	}
>
> full code.

Looks like you forgot a call to format before the opening 
parenthesis.

should be:
string sqlinsert = format(`INSERT INTO usersshapes (userlogin,
  uploading_date, geometry_type, data) VALUES ('%s', '%s', '%s',
  '%s') `, login, uploading_date, geometry_type, data);

because what ends up happening is :
     string sqlinsert = data;
which is almost certainly not what you want.


More information about the Digitalmars-d-learn mailing list