aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-09-28 09:07:30 +0000
committerstuconnolly <stuart02@gmail.com>2012-09-28 09:07:30 +0000
commitd01fe26b1e1965d81c6971a48a6b7856aa821cbf (patch)
treec9cb34b59db42f878c407203e60eaa81bb9d2527 /Frameworks
parentf8d12335468a8405c58f254c1044c8714778b437 (diff)
downloadsequelpro-d01fe26b1e1965d81c6971a48a6b7856aa821cbf.tar.gz
sequelpro-d01fe26b1e1965d81c6971a48a6b7856aa821cbf.tar.bz2
sequelpro-d01fe26b1e1965d81c6971a48a6b7856aa821cbf.zip
Tidy up binary handler.
Diffstat (limited to 'Frameworks')
-rw-r--r--Frameworks/PostgresKit/Source/PGPostgresTypeBinaryHandler.m32
-rw-r--r--Frameworks/PostgresKit/Source/PGPostgresTypes.h3
2 files changed, 4 insertions, 31 deletions
diff --git a/Frameworks/PostgresKit/Source/PGPostgresTypeBinaryHandler.m b/Frameworks/PostgresKit/Source/PGPostgresTypeBinaryHandler.m
index f544fb39..6c40ca14 100644
--- a/Frameworks/PostgresKit/Source/PGPostgresTypeBinaryHandler.m
+++ b/Frameworks/PostgresKit/Source/PGPostgresTypeBinaryHandler.m
@@ -36,13 +36,6 @@ static PGPostgresOid PGPostgresTypeBinaryTypes[] =
0
};
-@interface PGPostgresTypeBinaryHandler ()
-
-- (id)_binaryDataFromResult;
-
-@end
-
-
@implementation PGPostgresTypeBinaryHandler
@synthesize row = _row;
@@ -70,32 +63,13 @@ static PGPostgresOid PGPostgresTypeBinaryTypes[] =
- (id)objectFromResult
{
- if (!_result || !_type) return [NSNull null];
-
- switch (_type)
- {
- case PGPostgresOidByteData:
- return [self _binaryDataFromResult];
- }
-
- return [NSNull null];
-}
-
-#pragma mark -
-#pragma mark Private API
-
-/**
- * Converts a binary data value to an NSData instance.
- *
- * @return The NSData representation of the data.
- */
-- (id)_binaryDataFromResult
-{
PGbytea data;
+ if (!_result || !_type) return [NSNull null];
+
if (!PQgetf(_result, _row, PGPostgresResultValueByteA, _column)) return [NSNull null];
- if (!data.data || !data.len) return [NSNull null];
+ if (!data.data || !data.len) return [NSData data];
return [NSData dataWithBytes:data.data length:data.len];
}
diff --git a/Frameworks/PostgresKit/Source/PGPostgresTypes.h b/Frameworks/PostgresKit/Source/PGPostgresTypes.h
index 993e824d..c5812c4e 100644
--- a/Frameworks/PostgresKit/Source/PGPostgresTypes.h
+++ b/Frameworks/PostgresKit/Source/PGPostgresTypes.h
@@ -26,12 +26,11 @@
typedef Oid PGPostgresOid;
// See PostgreSQL source: include/catalog/pg_type.h
-
enum
{
// BOOL
PGPostgresOidBool = 16, // NumberHandler => NSNumber
- PGPostgresOidByteData = 17, // Currently not supported
+ PGPostgresOidByteData = 17, // BinaryHandler => NSData
// Text
PGPostgresOidName = 19, // StringHandler => NSString