From: helge Date: Thu, 24 Feb 2005 01:35:04 +0000 (+0000) Subject: improved SQL generation X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64f09cdccb1d681d824bb7d65ed37f2b3a51c978;p=sope improved SQL generation git-svn-id: http://svn.opengroupware.org/SOPE/trunk@595 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-gdl1/SQLite3/ChangeLog b/sope-gdl1/SQLite3/ChangeLog index 92d2ece9..9bd11fa8 100644 --- a/sope-gdl1/SQLite3/ChangeLog +++ b/sope-gdl1/SQLite3/ChangeLog @@ -1,5 +1,8 @@ 2005-02-24 Helge Hess + * NSString+SQLiteVal.m, NSCalendarDate+SQLiteVal.m: improved SQL value + generation (v4.5.14) + * v4.5.13 * NSString+SQLiteVal.m: fixed a warning on MacOSX diff --git a/sope-gdl1/SQLite3/NSCalendarDate+SQLiteVal.m b/sope-gdl1/SQLite3/NSCalendarDate+SQLiteVal.m index 2b4a8129..b1b8c1a0 100644 --- a/sope-gdl1/SQLite3/NSCalendarDate+SQLiteVal.m +++ b/sope-gdl1/SQLite3/NSCalendarDate+SQLiteVal.m @@ -171,6 +171,24 @@ static NSTimeZone *gmt02 = nil; NSTimeZone *serverTimeZone; NSString *format; NSString *val; + unsigned len; + unichar c1; + + if ((len = [_type length]) == 0) + c1 = 0; + else + c1 = [_type characterAtIndex:0]; + + if (c1 == 'i' || c1 == 'I') { // INTEGER + char buf[64]; + sprintf(buf, "%d", ((unsigned int)[self timeIntervalSince1970])); + return [NSString stringWithCString:buf]; + } + if (c1 == 'r' || c1 == 'R') { // REAL + char buf[64]; // TODO: check format + sprintf(buf, "%f", [self timeIntervalSince1970]); + return [NSString stringWithCString:buf]; + } if ((serverTimeZone = [_attribute serverTimeZone]) == nil ) { if (DefServerTimezone == nil) { diff --git a/sope-gdl1/SQLite3/NSString+SQLiteVal.m b/sope-gdl1/SQLite3/NSString+SQLiteVal.m index 31df0fdd..8a407f06 100644 --- a/sope-gdl1/SQLite3/NSString+SQLiteVal.m +++ b/sope-gdl1/SQLite3/NSString+SQLiteVal.m @@ -56,6 +56,8 @@ static Class EOExprClass = Nil; return self; } +/* generate SQL value */ + - (NSString *)stringValueForSQLite3Type:(NSString *)_type attribute:(EOAttribute *)_attribute { @@ -68,9 +70,9 @@ static Class EOExprClass = Nil; c1 = [_type characterAtIndex:0]; switch (c1) { - case 'c': case 'C': - case 'v': case 'V': - case 't': case 'T': { + case 'c': case 'C': // char + case 'v': case 'V': // varchar + case 't': case 'T': { // text NSString *s; id expr; @@ -95,13 +97,15 @@ static Class EOExprClass = Nil; [expr release]; return [s autorelease]; } - case 'm': case 'M': { - if (len < 5) { - if ([[_type lowercaseString] hasPrefix:@"money"]) - return [@"$" stringByAppendingString:self]; - } - break; + case 'i': case 'I': { // int + unsigned char buf[128]; + sprintf(buf, "%i", [self intValue]); + return [NSString stringWithCString:buf]; } + default: + NSLog(@"WARNING(%s): return string as is for type %@", + __PRETTY_FUNCTION__, _type); + break; } return self; } diff --git a/sope-gdl1/SQLite3/Version b/sope-gdl1/SQLite3/Version index 76aa6eb9..f61be538 100644 --- a/sope-gdl1/SQLite3/Version +++ b/sope-gdl1/SQLite3/Version @@ -1,3 +1,3 @@ # Version file -SUBMINOR_VERSION:=13 +SUBMINOR_VERSION:=14