Turn off automatic trimming by default

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@36500 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2013-04-10 15:03:55 +00:00
parent 395ebee3f4
commit b83f8363c5
8 changed files with 68 additions and 8 deletions

View file

@ -1,3 +1,16 @@
2013-04-10 Richard Frith-Macdonald <rfm@gnu.org>
* ECPG.pgm:
* MySQL.m:
* Oracle.pm:
* Postgres.m:
* SQLClient.h:
* SQLClient.m:
* GNUmakefile:
Change behavior to no longer trim leading and trailing space from
values retrieved from database by default.
Add method to restore automatic trimming for a connection if needed.
2013-03-04 Richard Frith-Macdonald <rfm@gnu.org>
* Version 1.6.1: released

View file

@ -557,7 +557,10 @@ static unsigned int trim(char *str)
case SQL3_CHARACTER_VARYING:
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:aString = DATA;
trim(aString);
if (_shouldTrim)
{
trim(aString);
}
v = [NSString stringWithUTF8String: aString];
free(aString);
break;
@ -586,7 +589,10 @@ static unsigned int trim(char *str)
default:
EXEC SQL GET DESCRIPTOR myDesc VALUE :index
:aString = DATA;
trim(aString);
if (_shouldTrim)
{
trim(aString);
}
v = [NSString stringWithUTF8String: aString];
free(aString);
if ([self debugging] > 0)

View file

@ -21,7 +21,7 @@ include $(GNUSTEP_MAKEFILES)/common.make
-include config.make
PACKAGE_NAME = SQLClient
PACKAGE_VERSION = 1.6.1
PACKAGE_VERSION = 1.7.0
CVS_MODULE_NAME = gnustep/dev-libs/SQLClient
CVS_TAG_NAME = SQLClient
SVN_BASE_URL=svn+ssh://svn.gna.org/svn/gnustep/libs
@ -34,7 +34,7 @@ TEST_TOOL_NAME=
LIBRARY_NAME=SQLClient
DOCUMENT_NAME=SQLClient
SQLClient_INTERFACE_VERSION=1.6
SQLClient_INTERFACE_VERSION=1.7
SQLClient_OBJC_FILES = SQLClient.m
SQLClient_LIBRARIES_DEPEND_UPON = -lPerformance

View file

@ -434,7 +434,10 @@ static unsigned int trim(char *str)
break;
default:
trim((char*)p);
if (YES == _shouldTrim)
{
trim((char*)p);
}
v = [NSString stringWithUTF8String: (char*)p];
break;
}

View file

@ -554,7 +554,10 @@ static unsigned int trim(char *str)
/* \0-pad the string. */
aString[octetLength] = '\0';
trim (aString);
if (YES == _shouldTrim)
{
trim (aString);
}
v = [NSString stringWithUTF8String: aString];
free(aString);
break;
@ -585,7 +588,10 @@ static unsigned int trim(char *str)
EXEC SQL GET DESCRIPTOR 'myDesc' VALUE :index
:aString = DATA;
aString[octetLength] = '\0';
trim (aString);
if (YES == _shouldTrim)
{
trim (aString);
}
v = [NSString stringWithUTF8String: aString];
free (aString);
NSLog(@"(Oracle) Unknown data type (%d) for '%s': '%@'",

View file

@ -619,10 +619,25 @@ static unsigned int trim(char *str)
v = [self dataFromBLOB: p];
break;
default:
case 18: // "char"
v = [NSString stringWithUTF8String: p];
break;
case 20: // INT8
case 21: // INT2
case 23: // INT4
trim(p);
v = [NSString stringWithUTF8String: p];
break;
case 25: // TEXT
default:
if (YES == _shouldTrim)
{
trim(p);
}
v = [NSString stringWithUTF8String: p];
break;
}
}
else // Binary

View file

@ -369,6 +369,12 @@ SQLCLIENT_PRIVATE
* set by the -begin, -commit or -rollback methods.
*/
BOOL _inTransaction; /** Are we inside a transaction? */
/**
* A flag indicating whether wleading and trailing white space in values
* read from the database shoud automatically be removed.<br />
* This should only be modified by the -setShouldTrim: method.
*/
BOOL _shouldTrim; /** Should whitespace be trimmed? */
NSString *_name; /** Unique identifier for instance */
NSString *_client; /** Identifier within backend */
NSString *_database; /** The configured database name/host */
@ -822,6 +828,12 @@ SQLCLIENT_PRIVATE
*/
- (void) setPassword: (NSString*)s;
/** Sets an internal flag to indicate whether leading and trailing white
* space characters should be removed from values retrieved from the
* database by the receiver.
*/
- (void) setShouldTrim: (BOOL)aFlag;
/**
* Set the database user for this object.<br />
* This is called automatically to configure the connection ...

View file

@ -1843,6 +1843,11 @@ static unsigned int maxConnections = 8;
}
}
- (void) setShouldTrim: (BOOL)aFlag
{
_shouldTrim = (YES == aFlag) ? YES : NO;
}
- (void) setUser: (NSString*)s
{
if ([s isEqual: _client] == NO)