Open ghost opened 3 years ago
This is in response to the change in last patch https://github.com/ProjectNami/projectnami/pull/422 to force use of Unicode on insert? So this would be another place in the code that needs updating?
Yes, need to add (N') here one more place to fully support Unicode in MSSQL.
@achariyeak : Are you sure about this? The requested change does not look right. The header comment just above that function states:
A format is one of '%d', '%f', '%s' (integer, float, string).
Your proposed change would result in queries containing something like ... VALUES (N%d, N%s, N%s)
(as an example), which would not work, especially when %d
and %f
are used.
Also, the $sql
variable at the end of that function gets sent to the prepare()
function anyway, so it will have string literals prefixed with N
.
What exactly are you trying to do that does not seem to be working? What does the "SELECT N'' AS NVARCHAR" in the title refer to? I suppose if you are passing in your own query, and if that query were to use a placeholder prefixed with N
(as in N'%s'
), then my fix in #422 would result in the query being re-written as ... NN'%s'
since the line that removes single-quotes (2 above the line that I fixed) does not account for N
prefixes. The simple fix/workaround is to remove the N
prefix. A more permanent solution would be to add a line above this one:
$query = str_replace( "'%s'", '%s', $query ); // Strip any existing single quotes.
being:
$query = str_replace( "N'%s'", '%s', $query ); // Strip any existing single quotes prefixed with "N".
Of course, this might not be the issue you are having, in which case we can either ignore this potential for the moment, or I can submit a separate PR for it, or maybe something else.
Again, please let us know precisely what you are trying to do, and why.
Thanks, Solomon..
It's now working fine,cause of my database table migration from existing one.
@achariyeak
It's now working fine, cause of my database table migration from existing one.
Ok, but can you please explain? Were your tables initially set up as VARCHAR
and are now NVARCHAR
? Was that the problem, or something else?
wp-db.php Line(2219) _insert_replace_helper // $formats = implode( ', ', $formats ); $formats = implode( ', N', $formats );