ObjPgSQL  Diff

Differences From Artifact [28af410d0c]:

To Artifact [77d330bc63]:


1




















2
3
4
5
6
7
8
#import "PGResultRow.h"





















@interface PGResultRowEnumerator: OFEnumerator
{
	PGResult *result;
	PGresult *res;
	int row, pos, count;
}

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#import "PGResultRow.h"

static id
convert_type(PGresult *res, int col, OFString *str)
{
	switch (PQftype(res, col)) {
	case 16: /* BOOLOID */
		if ([str isEqual: @"t"])
			return [OFNumber numberWithBool: YES];
		else
			return [OFNumber numberWithBool: NO];
	case 21: /* INT2OID */
		return [OFNumber numberWithInt16: (int16_t)[str decimalValue]];
	case 23: /* INT4OID */
		return [OFNumber numberWithInt32: (int32_t)[str decimalValue]];
	case 20: /* INT8OID */
		return [OFNumber numberWithInt64: (int64_t)[str decimalValue]];
	}

	return str;
}

@interface PGResultRowEnumerator: OFEnumerator
{
	PGResult *result;
	PGresult *res;
	int row, pos, count;
}
63
64
65
66
67
68
69

70
71
72
73
74
75
76
77
		col = [key intValue];
	else
		col = PQfnumber(res, [key UTF8String]);

	if (PQgetisnull(res, row, col))
		return nil;


	return [OFString stringWithUTF8String: PQgetvalue(res, row, col)];
}

- (OFEnumerator*)keyEnumerator
{
	return [[[PGResultRowKeyEnumerator alloc]
	    initWithResult: result
		       row: row] autorelease];







>
|







83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
		col = [key intValue];
	else
		col = PQfnumber(res, [key UTF8String]);

	if (PQgetisnull(res, row, col))
		return nil;

	return convert_type(res, col,
	    [OFString stringWithUTF8String: PQgetvalue(res, row, col)]);
}

- (OFEnumerator*)keyEnumerator
{
	return [[[PGResultRowKeyEnumerator alloc]
	    initWithResult: result
		       row: row] autorelease];
129
130
131
132
133
134
135

136
137
138

	while (pos < count && PQgetisnull(res, row, pos))
		pos++;

	if (pos >= count)
		return nil;


	return [OFString stringWithUTF8String: PQgetvalue(res, row, pos++)];
}
@end







>
|


150
151
152
153
154
155
156
157
158
159
160

	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