aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-09-07 09:57:31 +0000
committerstuconnolly <stuart02@gmail.com>2012-09-07 09:57:31 +0000
commite8bf8bf422b83a55cefd1bdf149f380a822eb880 (patch)
tree6c9b5114ca6be1aebb28e212352599018e4115a7
parent1a20cd03f29b0c0ee842008b1445ba54ad23dc69 (diff)
downloadsequelpro-e8bf8bf422b83a55cefd1bdf149f380a822eb880.tar.gz
sequelpro-e8bf8bf422b83a55cefd1bdf149f380a822eb880.tar.bz2
sequelpro-e8bf8bf422b83a55cefd1bdf149f380a822eb880.zip
Remove object quoting and keep track of data type support.
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryExecution.m4
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.h2
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.m23
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresConnectionUtils.m8
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m10
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h9
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m14
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m8
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresTypes.h129
9 files changed, 88 insertions, 119 deletions
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryExecution.m b/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryExecution.m
index 79951f59..29fcfea6 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryExecution.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryExecution.m
@@ -132,9 +132,7 @@ FLXQueryParamData;
for (int i = 0; i < paramData->paramNum; i++)
{
id nativeObject = [values objectAtIndex:i];
-
- NSParameterAssert(nativeObject);
-
+
// Deterime if bound value is an NSNull
if ([nativeObject isKindOfClass:[NSNull class]]) {
paramData->paramValues[i] = NULL;
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.h b/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.h
index 1d769b51..915b8c90 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.h
+++ b/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.h
@@ -24,8 +24,6 @@
@interface FLXPostgresConnection (FLXPostgresConnectionQueryPreparation)
-- (NSString *)quote:(NSObject *)object;
-
- (FLXPostgresStatement *)prepare:(NSString *)query;
- (FLXPostgresStatement *)prepareWithFormat:(NSString *)query, ...;
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.m b/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.m
index d8bf59b7..679237d1 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.m
@@ -29,29 +29,6 @@
@implementation FLXPostgresConnection (FLXPostgresConnectionQueryPreparation)
/**
- * Quotes the supplied object in accordance with it's data type.
- *
- * @param object The object to quote.
- *
- * @return A string representation of the quoted object.
- */
-- (NSString *)quote:(NSObject *)object
-{
- if (!object || [object isKindOfClass:[NSNull class]]) return @"NULL";
-
- id <FLXPostgresTypeHandlerProtocol> handler = [self typeHandlerForClass:[object class]];
-
- if (!handler) {
- [FLXPostgresException raise:FLXPostgresConnectionErrorDomain
- reason:[NSString stringWithFormat:@"Unsupported class '%@'", NSStringFromClass([object class])]];
-
- return nil;
- }
-
- return [handler quotedStringFromObject:object];
-}
-
-/**
* Creates a prepared statment from the supplied query.
*
* @param query The query to create the statement from.
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresConnectionUtils.m b/Frameworks/PostgresKit/Source/FLXPostgresConnectionUtils.m
index e988c7f2..73235766 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresConnectionUtils.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresConnectionUtils.m
@@ -49,7 +49,7 @@
*/
- (NSArray *)schemas
{
- return [self isConnected] ? [self _executeAndReturnResult:[NSString stringWithFormat:@"SELECT \"schema_name\" FROM \"information_schema\".\"schemata\" WHERE \"catalog_name\" = %@", [self quote:[self database]]]] : nil;
+ return [self isConnected] ? [self _executeAndReturnResult:[NSString stringWithFormat:@"SELECT \"schema_name\" FROM \"information_schema\".\"schemata\" WHERE \"catalog_name\" = '%@'", [self database]]] : nil;
}
/**
@@ -63,7 +63,7 @@
{
if (![self isConnected] || !schema || ![schema length]) return nil;
- return [self _executeAndReturnResult:[NSString stringWithFormat:@"SELECT \"table_name\" FROM \"information_schema\".\"tables\" WHERE \"table_catalog\" = %@ AND \"table_schema\" = %@ AND \"table_type\" = 'BASE TABLE'", [self quote:[self database]], [self quote:schema]]];
+ return [self _executeAndReturnResult:[NSString stringWithFormat:@"SELECT \"table_name\" FROM \"information_schema\".\"tables\" WHERE \"table_catalog\" = '%@' AND \"table_schema\" = '%@' AND \"table_type\" = 'BASE TABLE'",[self database], schema]];
}
/**
@@ -79,7 +79,7 @@
if (![self isConnected] || !table || ![table length] || !schema || ![schema length]) return nil;
NSString *join = @"\"information_schema\".\"table_constraints\" t INNER JOIN \"information_schema\".\"key_column_usage\" k ON t.\"constraint_name\" = k.\"constraint_name\"";
- NSString *where = [NSString stringWithFormat:@"t.\"constraint_type\" = 'PRIMARY KEY' AND t.\"table_catalog\" = %@ AND t.\"table_schema\" = %@ AND t.\"table_name\" = %@", [self quote:[self database]], [self quote:schema], [self quote:table]];
+ NSString *where = [NSString stringWithFormat:@"t.\"constraint_type\" = 'PRIMARY KEY' AND t.\"table_catalog\" = '%@' AND t.\"table_schema\" = '%@' AND t.\"table_name\" = '%@'", [self database], schema, table];
FLXPostgresResult *result = [self executeWithFormat:@"SELECT k.\"column_name\" FROM %@ WHERE %@", join, where];
@@ -98,7 +98,7 @@
{
if (![self isConnected] || !table || ![table length] || !schema || ![schema length]) return nil;
- return [self _executeAndReturnResult:[NSString stringWithFormat:@"SELECT \"column_name\" FROM \"information_schema\".\"columns\" WHERE \"table_catalog\" = %@ AND \"table_schema\" = %@ AND \"table_name\" = %@", [self quote:[self database]], [self quote:schema], [self quote:table]]];
+ return [self _executeAndReturnResult:[NSString stringWithFormat:@"SELECT \"column_name\" FROM \"information_schema\".\"columns\" WHERE \"table_catalog\" = '%@' AND \"table_schema\" = '%@' AND \"table_name\" = '%@'", [self database], schema, table]];
}
#pragma mark -
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m
index 8f8ace87..130d6590 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m
@@ -72,8 +72,6 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] =
- (NSData *)remoteDataFromObject:(id)object type:(FLXPostgresOid *)type
{
- if (!object || !type || ![object isKindOfClass:[NSDate class]]) return nil;
-
return nil;
}
@@ -101,14 +99,6 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] =
}
}
-- (NSString *)quotedStringFromObject:(id)object
-{
- if (!object || ![object isKindOfClass:[NSString class]]) return nil;
-
- // TODO: Imeplement me!
- return nil;
-}
-
#pragma mark -
#pragma mark Private API
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h
index 49261e60..2402bc56 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h
+++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandlerProtocol.h
@@ -72,13 +72,4 @@
*/
- (id)objectFromRemoteData:(const void *)bytes length:(NSUInteger)length type:(FLXPostgresOid)type;
-/**
- * Return a quoted string from an object.
- *
- * @param object The object to quote.
- *
- * @return A string represenation of the object quoted.
- */
-- (NSString *)quotedStringFromObject:(id)object;
-
@end
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m
index b31b4a34..d6cd7934 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m
@@ -305,20 +305,6 @@ static FLXPostgresOid FLXPostgresTypeNumberTypes[] =
return [self booleanObjectFromBytes:bytes length:length];
default:
return nil;
- }
-}
-
-- (NSString *)quotedStringFromObject:(id)object
-{
- if (!object || ![object isKindOfClass:[NSNumber class]]) return nil;
-
- const char *type = [object objCType];
-
- if (type[0] == 'c' || type[0] == 'C' || type[0] == 'B') {
- return ([(NSNumber *)object boolValue] ? @"true" : @"false");
- }
- else {
- return [(NSNumber *)object stringValue];
}
}
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m
index de1d064d..4e45ec40 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m
@@ -28,6 +28,7 @@ static FLXPostgresOid FLXPostgresTypeStringTypes[] =
{
FLXPostgresOidText,
FLXPostgresOidChar,
+ FLXPostgresOidName,
FLXPostgresOidVarchar,
FLXPostgresOidUnknown,
0
@@ -67,11 +68,4 @@ static FLXPostgresOid FLXPostgresTypeStringTypes[] =
return [[[NSString alloc] initWithBytes:bytes length:length encoding:[_connection stringEncoding]] autorelease];
}
-- (NSString *)quotedStringFromObject:(id)object
-{
- if (!object || ![object isKindOfClass:[NSString class]]) return nil;
-
- return [NSString stringWithFormat:@"'%@'", [[object description] stringByReplacingOccurrencesOfString:@"'" withString:@"''"]];
-}
-
@end
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypes.h b/Frameworks/PostgresKit/Source/FLXPostgresTypes.h
index 7c146e41..de6149c5 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresTypes.h
+++ b/Frameworks/PostgresKit/Source/FLXPostgresTypes.h
@@ -29,52 +29,87 @@ typedef Oid FLXPostgresOid;
enum
{
- FLXPostgresOidBool = 16,
- FLXPostgresOidData = 17,
- FLXPostgresOidName = 19,
- FLXPostgresOidInt8 = 20,
- FLXPostgresOidInt2 = 21,
- FLXPostgresOidInt4 = 23,
- FLXPostgresOidText = 25,
- FLXPostgresOidOid = 26,
- FLXPostgresOidXML = 142,
- FLXPostgresOidPoint = 600,
- FLXPostgresOidLSeg = 601,
- FLXPostgresOidPath = 602,
- FLXPostgresOidBox = 603,
- FLXPostgresOidPolygon = 604,
- FLXPostgresOidFloat4 = 700,
- FLXPostgresOidFloat8 = 701,
- FLXPostgresOidAbsTime = 702,
- FLXPostgresOidUnknown = 705,
- FLXPostgresOidCircle = 718,
- FLXPostgresOidMoney = 790,
- FLXPostgresOidMacAddr = 829,
- FLXPostgresOidIPAddr = 869,
- FLXPostgresOidNetAddr = 869,
- FLXPostgresOidArrayBool = 1000,
- FLXPostgresOidArrayData = 1001,
- FLXPostgresOidArrayChar = 1002,
- FLXPostgresOidArrayName = 1003,
- FLXPostgresOidArrayInt2 = 1005,
- FLXPostgresOidArrayInt4 = 1007,
- FLXPostgresOidArrayText = 1009,
- FLXPostgresOidArrayVarchar = 1015,
- FLXPostgresOidArrayInt8 = 1016,
- FLXPostgresOidArrayFloat4 = 1021,
- FLXPostgresOidArrayFloat8 = 1022,
- FLXPostgresOidArrayMacAddr = 1040,
- FLXPostgresOidArrayIPAddr = 1041,
- FLXPostgresOidChar = 1042,
- FLXPostgresOidVarchar = 1043,
- FLXPostgresOidDate = 1082,
- FLXPostgresOidTime = 1083,
- FLXPostgresOidTimestamp = 1114,
- FLXPostgresOidTimestampTZ = 1184,
+ // BOOL
+ FLXPostgresOidBool = 16, // NumberHandler
+ FLXPostgresOidData = 17, // Currently not supported
+
+ // Text
+ FLXPostgresOidName = 19, // StringHandler
+
+ // Integers
+ FLXPostgresOidInt8 = 20, // NumberHandler
+ FLXPostgresOidInt2 = 21, // NumberHandler
+ FLXPostgresOidInt4 = 23, // NumberHandler
+
+ // Text
+ FLXPostgresOidText = 25, // StringHandler
+
+ // OID
+ FLXPostgresOidOid = 26, // Currently not supported
+
+ // XML
+ FLXPostgresOidXML = 142, // Currently not supported
+
+ // Geometric
+ FLXPostgresOidPoint = 600, // Currently not supported
+ FLXPostgresOidLSeg = 601, // Currently not supported
+ FLXPostgresOidPath = 602, // Currently not supported
+ FLXPostgresOidBox = 603, // Currently not supported
+ FLXPostgresOidPolygon = 604, // Currently not supported
+
+ // Float
+ FLXPostgresOidFloat4 = 700, // NumberHandler
+ FLXPostgresOidFloat8 = 701, // NumberHandler
+
+ // ABS Time
+ FLXPostgresOidAbsTime = 702, // DateHandler
+
+ // What!
+ FLXPostgresOidUnknown = 705, // StringHandler
+
+ // Geometric
+ FLXPostgresOidCircle = 718, // Currently not supported
+
+ // Monetary
+ FLXPostgresOidMoney = 790, // Currently not supported
+
+ // Network
+ FLXPostgresOidMacAddr = 829, // Currently not supported
+ FLXPostgresOidIPAddr = 869, // Currently not supported
+ FLXPostgresOidNetAddr = 869, // Currently not supported
+
+ // Arrays
+ FLXPostgresOidArrayBool = 1000, // Currently not supported
+ FLXPostgresOidArrayData = 1001, // Currently not supported
+ FLXPostgresOidArrayChar = 1002, // Currently not supported
+ FLXPostgresOidArrayName = 1003, // Currently not supported
+ FLXPostgresOidArrayInt2 = 1005, // Currently not supported
+ FLXPostgresOidArrayInt4 = 1007, // Currently not supported
+ FLXPostgresOidArrayText = 1009, // Currently not supported
+ FLXPostgresOidArrayVarchar = 1015, // Currently not supported
+ FLXPostgresOidArrayInt8 = 1016, // Currently not supported
+ FLXPostgresOidArrayFloat4 = 1021, // Currently not supported
+ FLXPostgresOidArrayFloat8 = 1022, // Currently not supported
+ FLXPostgresOidArrayMacAddr = 1040, // Currently not supported
+ FLXPostgresOidArrayIPAddr = 1041, // Currently not supported
+
+ // Text
+ FLXPostgresOidChar = 1042, // StringHandler
+ FLXPostgresOidVarchar = 1043, // StringHandler
+
+ // Date/time
+ FLXPostgresOidDate = 1082, // DateHandler
+ FLXPostgresOidTime = 1083, // DateHandler
+ FLXPostgresOidTimestamp = 1114, // DateHandler
+ FLXPostgresOidTimestampTZ = 1184, // DateHandler
FLXPostgresOidInterval = 1186,
- FLXPostgresOidTimeTZ = 1266,
- FLXPostgresOidBit = 1560,
- FLXPostgresOidVarbit = 1562,
- FLXPostgresOidNumeric = 1700,
- FLXPostgresOidMax = 1700
+ FLXPostgresOidTimeTZ = 1266, // DateHandler
+
+ // Binary
+ FLXPostgresOidBit = 1560, // Currently not supported
+ FLXPostgresOidVarbit = 1562, // Currently not supported
+
+ // Numeric
+ FLXPostgresOidNumeric = 1700, // Currently not supported
+ FLXPostgresOidMax = 1700 // Currently not supported
};