@@ -1,7 +1,7 @@ /* - * Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017 + * Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 * Jonathan Schleifer * * https://heap.zone/git/objpgsql.git * * Permission to use, copy, modify, and/or distribute this software for any @@ -59,11 +59,11 @@ else connectionInfo = [OFMutableString stringWithFormat: @"%@=%@", key, object]; } - if ((_connection = PQconnectdb([connectionInfo UTF8String])) == NULL) + if ((_connection = PQconnectdb(connectionInfo.UTF8String)) == NULL) @throw [OFOutOfMemoryException exception]; if (PQstatus(_connection) == CONNECTION_BAD) @throw [PGConnectionFailedException exceptionWithConnection: self]; @@ -84,11 +84,11 @@ _connection = NULL; } - (PGResult *)executeCommand: (OFConstantString *)command { - PGresult *result = PQexec(_connection, [command UTF8String]); + PGresult *result = PQexec(_connection, command.UTF8String); if (PQresultStatus(result) == PGRES_FATAL_ERROR) { PQclear(result); @throw [PGCommandFailedException exceptionWithConnection: self @@ -132,30 +132,30 @@ if ([parameter isKindOfClass: [OFString class]]) values[i++] = [parameter UTF8String]; else if ([parameter isKindOfClass: [OFNumber class]]) { OFNumber *number = parameter; - switch ([number type]) { + switch (number.type) { case OF_NUMBER_TYPE_BOOL: - if ([number boolValue]) + if (number.boolValue) values[i++] = "t"; else values[i++] = "f"; break; default: - values[i++] = [[number description] - UTF8String]; + values[i++] = + number.description.UTF8String; break; } } else if ([parameter isKindOfClass: [OFNull class]]) values[i++] = NULL; else - values[i++] = [[parameter description] - UTF8String]; + values[i++] = + [parameter description].UTF8String; } while ((parameter = va_arg(args, id)) != nil); - result = PQexecParams(_connection, [command UTF8String], + result = PQexecParams(_connection, command.UTF8String, argsCount, NULL, values, NULL, NULL, 0); } @finally { [self freeMemory: values]; } @@ -188,11 +188,11 @@ command = [OFMutableString stringWithString: @"INSERT INTO "]; [command appendString: table]; [command appendString: @" ("]; - count = [row count]; + count = row.count; i = 0; enumerator = [row keyEnumerator]; while ((key = [enumerator nextObject]) != nil) { if (i > 0) @@ -212,18 +212,18 @@ enumerator = [row objectEnumerator]; while ((value = [enumerator nextObject]) != nil) { if (i > 0) [command appendString: @", "]; - values[i] = [value UTF8String]; + values[i] = value.UTF8String; [command appendFormat: @"$%zd", ++i]; } [command appendString: @")"]; - result = PQexecParams(_connection, [command UTF8String], + result = PQexecParams(_connection, command.UTF8String, (int)count, NULL, values, NULL, NULL, 0); } @finally { [self freeMemory: values]; }