ObjPgSQL  Check-in [bec524d06b]

Overview
Comment:Adjust to ObjFW changes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bec524d06bdfb4ce57a88ef307fb1fc93eaa01201ff20c221814f404891d1009
User & Date: js on 2014-07-18 21:40:09
Other Links: manifest | tags
Context
2014-07-18
23:35
Add a proper build system check-in: 8679c61b2c user: js tags: trunk
21:40
Adjust to ObjFW changes check-in: bec524d06b user: js tags: trunk
2013-07-23
14:11
Improve exceptions. check-in: 12b5ef483a user: js tags: trunk
Changes

Modified PGConnection.m from [d9f8dfd676] to [85877956d2].

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
		do {
			if ([parameter isKindOfClass: [OFString class]])
				values[i++] = [parameter UTF8String];
			else if ([parameter isKindOfClass: [OFNumber class]]) {
				OFNumber *number = parameter;

				switch ([number type]) {
				case OF_NUMBER_BOOL:
					if ([number boolValue])
						values[i++] = "t";
					else
						values[i++] = "f";
					break;
				default:
					values[i++] = [[number description]







|







110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
		do {
			if ([parameter isKindOfClass: [OFString class]])
				values[i++] = [parameter UTF8String];
			else if ([parameter isKindOfClass: [OFNumber class]]) {
				OFNumber *number = parameter;

				switch ([number type]) {
				case OF_NUMBER_TYPE_BOOL:
					if ([number boolValue])
						values[i++] = "t";
					else
						values[i++] = "f";
					break;
				default:
					values[i++] = [[number description]

Modified PGResultRow.m from [751cf4cc9f] to [bc24366b2f].

1
2
3
4
5
6
7
8
9
10
11
#import "PGResultRow.h"

static id
convert_type(PGresult *res, int column, OFString *string)
{
	switch (PQftype(res, column)) {
	case 16:  /* BOOLOID */
		if ([string isEqual: @"t"])
			return [OFNumber numberWithBool: YES];
		else
			return [OFNumber numberWithBool: NO];



|







1
2
3
4
5
6
7
8
9
10
11
#import "PGResultRow.h"

static id
convertType(PGresult *res, int column, OFString *string)
{
	switch (PQftype(res, column)) {
	case 16:  /* BOOLOID */
		if ([string isEqual: @"t"])
			return [OFNumber numberWithBool: YES];
		else
			return [OFNumber numberWithBool: NO];
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
		column = [key intValue];
	else
		column = PQfnumber(_res, [key UTF8String]);

	if (PQgetisnull(_res, _row, column))
		return nil;

	return convert_type(_res, column,
	    [OFString stringWithUTF8String: PQgetvalue(_res, _row, column)]);
}

- (OFEnumerator*)keyEnumerator
{
	return [[[PGResultRowKeyEnumerator alloc]
	    initWithResult: _result







|







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
		column = [key intValue];
	else
		column = PQfnumber(_res, [key UTF8String]);

	if (PQgetisnull(_res, _row, column))
		return nil;

	return convertType(_res, column,
	    [OFString stringWithUTF8String: PQgetvalue(_res, _row, column)]);
}

- (OFEnumerator*)keyEnumerator
{
	return [[[PGResultRowKeyEnumerator alloc]
	    initWithResult: _result
196
197
198
199
200
201
202
203
204
205
206

	while (_pos < _count && PQgetisnull(_res, _row, _pos))
		_pos++;

	if (_pos >= _count)
		return nil;

	return convert_type(_res, _pos,
	    [OFString stringWithUTF8String: PQgetvalue(_res, _row, _pos++)]);
}
@end







|



196
197
198
199
200
201
202
203
204
205
206

	while (_pos < _count && PQgetisnull(_res, _row, _pos))
		_pos++;

	if (_pos >= _count)
		return nil;

	return convertType(_res, _pos,
	    [OFString stringWithUTF8String: PQgetvalue(_res, _row, _pos++)]);
}
@end

Modified exceptions/PGException.m from [63db1fe590] to [4cb1491070].

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
	self = [super init];

	@try {
		_connection = [connection retain];
		_error = [[OFString alloc]
		    initWithCString: PQerrorMessage([_connection PG_connection])
			   encoding: OF_STRING_ENCODING_NATIVE];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
	self = [super init];

	@try {
		_connection = [connection retain];
		_error = [[OFString alloc]
		    initWithCString: PQerrorMessage([_connection PG_connection])
			   encoding: [OFString nativeOSEncoding]];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}