diff --git a/ChangeLog b/ChangeLog index 5d13703..51c12e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2013-04-10 Richard Frith-Macdonald + + * 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 * Version 1.6.1: released diff --git a/ECPG.pgm b/ECPG.pgm index c16a98d..c4b5532 100644 --- a/ECPG.pgm +++ b/ECPG.pgm @@ -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) diff --git a/GNUmakefile b/GNUmakefile index a58380b..dc68bb5 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -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 diff --git a/MySQL.m b/MySQL.m index 253e132..7a6013b 100644 --- a/MySQL.m +++ b/MySQL.m @@ -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; } diff --git a/Oracle.pm b/Oracle.pm index 93f062a..de1fa9e 100644 --- a/Oracle.pm +++ b/Oracle.pm @@ -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': '%@'", diff --git a/Postgres.m b/Postgres.m index d85fcb4..f5efd18 100644 --- a/Postgres.m +++ b/Postgres.m @@ -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 diff --git a/SQLClient.h b/SQLClient.h index 378b17d..03f1a63 100644 --- a/SQLClient.h +++ b/SQLClient.h @@ -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.
+ * 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.
* This is called automatically to configure the connection ... diff --git a/SQLClient.m b/SQLClient.m index 04dad8e..d838f58 100644 --- a/SQLClient.m +++ b/SQLClient.m @@ -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)