diff options
Diffstat (limited to 'Frameworks/PostgresKit')
-rw-r--r-- | Frameworks/PostgresKit/PostgresKit.xcodeproj/project.pbxproj | 32 | ||||
-rw-r--r-- | Frameworks/PostgresKit/Resources/TestData.sql | 4 | ||||
-rwxr-xr-x | Frameworks/PostgresKit/Scripts/build-libpq.sh | 4 | ||||
-rw-r--r-- | Frameworks/PostgresKit/Source/PGPostgresTimeTZ.h | 4 | ||||
-rw-r--r-- | Frameworks/PostgresKit/Source/PGPostgresTimeTZ.m | 29 | ||||
-rw-r--r-- | Frameworks/PostgresKit/Source/PostgresKit.h | 1 | ||||
-rw-r--r-- | Frameworks/PostgresKit/Tests/PGDataTypeTests.m | 30 |
7 files changed, 61 insertions, 43 deletions
diff --git a/Frameworks/PostgresKit/PostgresKit.xcodeproj/project.pbxproj b/Frameworks/PostgresKit/PostgresKit.xcodeproj/project.pbxproj index b2cb37cd..b534f8aa 100644 --- a/Frameworks/PostgresKit/PostgresKit.xcodeproj/project.pbxproj +++ b/Frameworks/PostgresKit/PostgresKit.xcodeproj/project.pbxproj @@ -11,7 +11,7 @@ 170465CF15C2960F00DC5BE5 /* PGPostgresTypeHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 170465CD15C2960F00DC5BE5 /* PGPostgresTypeHandler.m */; }; 171D58701612E9B900F84472 /* PGDataTypeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 171D586F1612E9B900F84472 /* PGDataTypeTests.m */; }; 1724C9B815F9ED8600AB2291 /* libpqtypes.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1724C9B715F9ED8600AB2291 /* libpqtypes.a */; }; - 1724CC9215FB4CC200AB2291 /* PGPostgresTimeTZ.h in Headers */ = {isa = PBXBuildFile; fileRef = 1724CC9015FB4CC200AB2291 /* PGPostgresTimeTZ.h */; }; + 1724CC9215FB4CC200AB2291 /* PGPostgresTimeTZ.h in Headers */ = {isa = PBXBuildFile; fileRef = 1724CC9015FB4CC200AB2291 /* PGPostgresTimeTZ.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1724CC9315FB4CC200AB2291 /* PGPostgresTimeTZ.m in Sources */ = {isa = PBXBuildFile; fileRef = 1724CC9115FB4CC200AB2291 /* PGPostgresTimeTZ.m */; }; 1724CD1515FB69EC00AB2291 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17E595F114F3058F0054EE08 /* Foundation.framework */; }; 1724CD1815FB6A0500AB2291 /* PostgresKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* PostgresKit.framework */; }; @@ -641,11 +641,7 @@ 17E5952D14F302740054EE08 /* Distribution */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - i386, - ppc, - x86_64, - ); + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Source/PostgresKit-Prefix.pch"; @@ -655,8 +651,8 @@ INFOPLIST_FILE = Resources/Info.plist; INFOPLIST_PREFIX_HEADER = ""; PREBINDING = NO; - SDKROOT = macosx10.5; - VALID_ARCHS = "i386 ppc x86_64"; + SDKROOT = macosx10.6; + VALID_ARCHS = "i386 x86_64"; }; name = Distribution; }; @@ -807,11 +803,7 @@ 1DEB91B208733DA50010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - i386, - ppc, - x86_64, - ); + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -823,19 +815,15 @@ INFOPLIST_PREFIX_HEADER = ""; ONLY_ACTIVE_ARCH = YES; PREBINDING = NO; - SDKROOT = macosx10.5; - VALID_ARCHS = "i386 ppc x86_64"; + SDKROOT = macosx10.6; + VALID_ARCHS = "i386 x86_64"; }; name = Debug; }; 1DEB91B308733DA50010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - i386, - ppc, - x86_64, - ); + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Source/PostgresKit-Prefix.pch"; @@ -845,8 +833,8 @@ INFOPLIST_FILE = Resources/Info.plist; INFOPLIST_PREFIX_HEADER = ""; PREBINDING = NO; - SDKROOT = macosx10.5; - VALID_ARCHS = "i386 ppc x86_64"; + SDKROOT = macosx10.6; + VALID_ARCHS = "i386 x86_64"; }; name = Release; }; diff --git a/Frameworks/PostgresKit/Resources/TestData.sql b/Frameworks/PostgresKit/Resources/TestData.sql index e351f43f..574d1702 100644 --- a/Frameworks/PostgresKit/Resources/TestData.sql +++ b/Frameworks/PostgresKit/Resources/TestData.sql @@ -58,9 +58,9 @@ VALUES ( 'VARCHAR', '08-04-1987', '02:02:02', - '02:02:02 GMT', + '02:02:02 +1000', '08-04-1987 02:02:02', - '08-04-1987 02:02:02 GMT'); + '08-04-1987 02:02:02 +0000'); COMMIT; diff --git a/Frameworks/PostgresKit/Scripts/build-libpq.sh b/Frameworks/PostgresKit/Scripts/build-libpq.sh index 43e8a48e..dd5f24ec 100755 --- a/Frameworks/PostgresKit/Scripts/build-libpq.sh +++ b/Frameworks/PostgresKit/Scripts/build-libpq.sh @@ -43,8 +43,8 @@ QUIET='NO' CLEAN='NO' # Configuration -MIN_OS_X_VERSION='10.5' -ARCHITECTURES='-arch ppc -arch i386 -arch x86_64' +MIN_OS_X_VERSION='10.6' +ARCHITECTURES='-arch i386 -arch x86_64' CONFIGURE_OPTIONS='--enable-thread-safety --with-openssl' COMMON_COMPILE_OPTIONS="-fno-omit-frame-pointer -fno-exceptions -mmacosx-version-min=${MIN_OS_X_VERSION}" diff --git a/Frameworks/PostgresKit/Source/PGPostgresTimeTZ.h b/Frameworks/PostgresKit/Source/PGPostgresTimeTZ.h index 075ffbb0..0101ffa3 100644 --- a/Frameworks/PostgresKit/Source/PGPostgresTimeTZ.h +++ b/Frameworks/PostgresKit/Source/PGPostgresTimeTZ.h @@ -48,12 +48,12 @@ /** * @property date The date instance that holds the time. */ -@property (readonly) NSDate *date; +@property (readwrite, retain) NSDate *date; /** * @property timeZone The time zone of the associated time. */ -@property (readonly) NSTimeZone *timeZone; +@property (readwrite, retain) NSTimeZone *timeZone; + (PGPostgresTimeTZ *)timeWithDate:(NSDate *)date timeZoneGMTOffset:(NSUInteger)offset; diff --git a/Frameworks/PostgresKit/Source/PGPostgresTimeTZ.m b/Frameworks/PostgresKit/Source/PGPostgresTimeTZ.m index d2d91898..c4f14eb5 100644 --- a/Frameworks/PostgresKit/Source/PGPostgresTimeTZ.m +++ b/Frameworks/PostgresKit/Source/PGPostgresTimeTZ.m @@ -57,9 +57,10 @@ - (id)initWithDate:(NSDate *)date timeZoneGMTOffset:(NSUInteger)offset { if ((self = [super init])) { - _date = date; _hasDate = NO; - _timeZone = [NSTimeZone timeZoneForSecondsFromGMT:offset]; + + [self setDate:date]; + [self setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:offset]]; } return self; @@ -67,6 +68,20 @@ #pragma mark - +- (NSUInteger)hash +{ + return [_date hash] ^ [_timeZone hash]; +} + +- (BOOL)isEqual:(id)object +{ + if (object == self) return YES; + + if (!object || ![object isKindOfClass:[self class]]) return NO; + + return [_date isEqualToDate:[(PGPostgresTimeTZ *)object date]] && [_timeZone isEqualToTimeZone:[(PGPostgresTimeTZ *)object timeZone]]; +} + - (NSString *)description { NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; @@ -81,4 +96,14 @@ return [NSString stringWithFormat:@"%@ %@", output, [_timeZone abbreviation]]; } +#pragma mark - + +- (void)dealloc +{ + if (_date) [_date release], _date = nil; + if (_timeZone) [_timeZone release], _timeZone = nil; + + [super dealloc]; +} + @end diff --git a/Frameworks/PostgresKit/Source/PostgresKit.h b/Frameworks/PostgresKit/Source/PostgresKit.h index 4189fffe..49d15b09 100644 --- a/Frameworks/PostgresKit/Source/PostgresKit.h +++ b/Frameworks/PostgresKit/Source/PostgresKit.h @@ -20,6 +20,7 @@ #import "PGPostgresError.h" #import "PGPostgresResult.h" +#import "PGPostgresTimeTZ.h" #import "PGPostgresStatement.h" #import "PGPostgresException.h" #import "PGPostgresConnection.h" diff --git a/Frameworks/PostgresKit/Tests/PGDataTypeTests.m b/Frameworks/PostgresKit/Tests/PGDataTypeTests.m index 629ec32a..765404a3 100644 --- a/Frameworks/PostgresKit/Tests/PGDataTypeTests.m +++ b/Frameworks/PostgresKit/Tests/PGDataTypeTests.m @@ -30,6 +30,8 @@ #import "PGDataTypeTests.h" +#import <PostgresKit/PostgresKit.h> + static NSString *PGTestDatabaseHost = @"localhost"; static NSString *PGTestDatabaseUser = @"pgkit_test"; static NSString *PGTestDatabaseName = @"pgkit_test"; @@ -72,11 +74,18 @@ static NSUInteger PGTestDatabasePort = 5432; [self _addTestForField:@"numeric" withExpectedResult:[NSNumber numberWithDouble:12345.678] connection:connection toTestSuite:testSuite]; [self _addTestForField:@"char" withExpectedResult:@"CHAR" connection:connection toTestSuite:testSuite]; [self _addTestForField:@"varchar" withExpectedResult:@"VARCHAR" connection:connection toTestSuite:testSuite]; - //[self _addTestForField:@"date" withExpectedResult: connection:connection toTestSuite:testSuite]; - //[self _addTestForField:@"time" withExpectedResult: connection:connection toTestSuite:testSuite]; - //[self _addTestForField:@"timetz" withExpectedResult: connection:connection toTestSuite:testSuite]; - //[self _addTestForField:@"timestamp" withExpectedResult: connection:connection toTestSuite:testSuite]; - //[self _addTestForField:@"timestamptz" withExpectedResult: connection:connection toTestSuite:testSuite]; + [self _addTestForField:@"date" withExpectedResult:[NSDate dateWithTimeIntervalSince1970:544834800] connection:connection toTestSuite:testSuite]; + [self _addTestForField:@"time" withExpectedResult:[NSDate dateWithTimeIntervalSince1970:946692122] connection:connection toTestSuite:testSuite]; + [self _addTestForField:@"timestamp" withExpectedResult:[NSDate dateWithTimeIntervalSince1970:544845722] connection:connection toTestSuite:testSuite]; + + PGPostgresTimeTZ *timeTz = [PGPostgresTimeTZ timeWithDate:[NSDate dateWithTimeIntervalSince1970:946692122] timeZoneGMTOffset:36000]; + PGPostgresTimeTZ *timestampTz = [PGPostgresTimeTZ timeWithDate:[NSDate dateWithTimeIntervalSince1970:544845722] timeZoneGMTOffset:3600]; + + [timeTz setHasDate:YES]; + [timestampTz setHasDate:YES]; + + [self _addTestForField:@"timetz" withExpectedResult:timeTz connection:connection toTestSuite:testSuite]; + [self _addTestForField:@"timestamptz" withExpectedResult:timestampTz connection:connection toTestSuite:testSuite]; [connection release]; @@ -112,22 +121,17 @@ static NSUInteger PGTestDatabasePort = 5432; #pragma mark - #pragma mark Tests -- (void)testResultValueIsNotNull +- (void)testResultValueIsNotNil { STAssertNotNil(_result, nil); } -- (void)testResultIsOfCorrectType +- (void)testResultIsOfCorrectTypeAndValue { - STAssertEquals([_result class], [_expectedResult class], @"Expected _result to be of type %@, but is actually %@", [_expectedResult className], [_result className]); -} - -- (void)testResultHasCorrectValue -{ STAssertEqualObjects(_result, _expectedResult, nil); } -#pragma mark -r +#pragma mark - #pragma mark Private API - (void)_establishConnection |