discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A problem with quoteString in libSQLClient, and a question


From: Sebastian Reitenbach
Subject: A problem with quoteString in libSQLClient, and a question
Date: Wed, 12 Dec 2012 16:54:12 +0100
User-agent: SOGoMail 2.0.3

Hi,

for MPDCon, I use libSQLClient to save some data in a local SQLite database.
So far, everything works not too bad, I only have a problem with quoting 
strings:
libSQLClient provides a quoteString: method, which I thought I can use
to quote ' characters in the string. 
Now, when I don't quote the string, or when I use the libSQLClient method
quoteString, then MPDCon hangs, when it comes to a, in my case a file name,
containing a ' character.

When I use NSStrings  stringByReplacingOccurrencesOfString: withString:
as below, then it just quotes it right, and the query executes fine.

Code example is shown below:


- (void) setRating: (NSInteger) rating forFile: (NSString *) fileName
{
  NSString *quotedFileName, *query;

  // the following doesn't seem to work, but the line after it does the trick!
  //quotedFileName = [MPDConDB quoteString:fileName];
  quotedFileName = [fileName stringByReplacingOccurrencesOfString:@"'" 
withString:@"''"];
  query = [NSString stringWithFormat:@"INSERT OR REPLACE INTO \
                SongRatings(fileName, rating) values('%@', %i)", 
quotedFileName, rating];
  [MPDConDB execute: query, nil];
}


the question I have to libSQLClient is, whether there is a method I can query 
the 
SQLClient object, which database backends it supports?
For example, on different systems, there may be backends for sqlite available,
on others not, depending on how libSQLClient was compiled. 
So far I haven't seen anything, but maybe overlooked it.

thanks,
Sebastian




reply via email to

[Prev in Thread] Current Thread [Next in Thread]