|
killergate Novice
Joined: 16 Feb 2009 Posts: 38
|
Posted: Thu Feb 04, 2010 10:34 pm
[3.12] %quote bug? |
Hi,
I've tried searching for existing issues with %quote, but havent found one matching my observations, so here goes:
I've got a script that looks at a room's roomname and tries to locate the mapper location - similar to #find.
What I've run into is the following:
Ive got a roomname called "Killergate's home" (stored in @vCurrName)
and when I try to do this:
Code: |
#VAR vPossibleRooms %mapquery(%concat("[Name] = '",%quote( @vCurrName ),"'")) {} AdvancedFind |
I don't get any possible room hits - as @vCurrName contains an apostrophe and breaks the mapquery. How can I make sure I dont run into this problem with special characters?
%quote(@vCurrName) does nothing - regardless of how many special characters I put into the variable.
/kg |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Feb 04, 2010 11:11 pm |
The %quote function will put the current "quote character" (defined in the Special Characters) in front of other CMUD special characters. For example:
Code: |
#SHOW %quote("test # hello") |
will display
because ~ is the default quote character and # is the special character for commands.
A single apostrophe is not a special character in CMUD. The problem you are experiencing is that the apostrophe is a special character for SQL and database filter commands. How you "quote" an apostrophe depends upon the database and filter string syntax. It's been a while since I played with %mapquery, so I forget if you use the \ backslash before the apostrophe, or if you just use a double-apostrophe. But you can handle this using the %replace function:
Code: |
%replace(@vCurrName,"'","\'") |
or something like that.
I'll probably eventually add some sort of "sqlquote" function to handle this since it will be more needed now with the %sql and #SQLDB scripting. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|