@@ -39,17 +39,15 @@ connectionInfo = [OFMutableString stringWithFormat: @"%@=%@", key, object]; } if ((_connnection = PQconnectdb([connectionInfo UTF8String])) == NULL) - @throw [OFOutOfMemoryException - exceptionWithClass: [self class]]; + @throw [OFOutOfMemoryException exception]; if (PQstatus(_connnection) == CONNECTION_BAD) @throw [PGConnectionFailedException - exceptionWithClass: [self class] - connection: self]; + exceptionWithConnection: self]; [pool release]; } - (void)reset @@ -70,13 +68,12 @@ PGresult *result = PQexec(_connnection, [command UTF8String]); if (PQresultStatus(result) == PGRES_FATAL_ERROR) { PQclear(result); @throw [PGCommandFailedException - exceptionWithClass: [self class] - connection: self - command: command]; + exceptionWithConnection: self + command: command]; } switch (PQresultStatus(result)) { case PGRES_TUPLES_OK: return [PGResult PG_resultWithResult: result]; @@ -84,13 +81,12 @@ PQclear(result); return nil; default: PQclear(result); @throw [PGCommandFailedException - exceptionWithClass: [self class] - connection: self - command: command]; + exceptionWithConnection: self + command: command]; } } - (PGResult*)executeCommand: (OFConstantString*)command parameters: (id)parameter, ... @@ -113,19 +109,21 @@ do { if ([parameter isKindOfClass: [OFString class]]) values[i++] = [parameter UTF8String]; else if ([parameter isKindOfClass: [OFNumber class]]) { - switch ([parameter type]) { + OFNumber *number = parameter; + + switch ([number type]) { case OF_NUMBER_BOOL: - if ([parameter boolValue]) + if ([number boolValue]) values[i++] = "t"; else values[i++] = "f"; break; default: - values[i++] = [[parameter description] + values[i++] = [[number description] UTF8String]; break; } } else if ([parameter isKindOfClass: [OFNull class]]) values[i++] = NULL; @@ -149,13 +147,12 @@ PQclear(result); return nil; default: PQclear(result); @throw [PGCommandFailedException - exceptionWithClass: [self class] - connection: self - command: command]; + exceptionWithConnection: self + command: command]; } } - (void)insertRow: (OFDictionary*)row intoTable: (OFString*)table @@ -212,13 +209,12 @@ [pool release]; if (PQresultStatus(result) != PGRES_COMMAND_OK) { PQclear(result); @throw [PGCommandFailedException - exceptionWithClass: [self class] - connection: self - command: command]; + exceptionWithConnection: self + command: command]; } PQclear(result); }