Add support for retrieving columns
FossilOrigin-Name: 727a6838a567ab678c28cb0dfc2b95aaa4fa9b5af7b29e9f9833ffd81cea8d9d
This commit is contained in:
parent
f7aa1209f7
commit
5967ebf3b7
3 changed files with 82 additions and 2 deletions
|
@ -64,6 +64,37 @@ OF_APPLICATION_DELEGATE(Tests)
|
|||
nil]];
|
||||
[stmt step];
|
||||
|
||||
stmt = [conn prepareStatement: @"SELECT * FROM test"];
|
||||
for (size_t i = 0; [stmt step]; i++) {
|
||||
OF_ENSURE([stmt columnCount] == 3);
|
||||
OF_ENSURE([[stmt nameForColumn: 0] isEqual: @"a"]);
|
||||
OF_ENSURE([[stmt nameForColumn: 1] isEqual: @"b"]);
|
||||
OF_ENSURE([[stmt nameForColumn: 2] isEqual: @"c"]);
|
||||
|
||||
switch (i) {
|
||||
case 0:
|
||||
OF_ENSURE([[stmt objectForColumn: 0]
|
||||
isEqual: [OFNumber numberWithInt: 5]]);
|
||||
OF_ENSURE([[stmt objectForColumn: 1]
|
||||
isEqual: @"String"]);
|
||||
OF_ENSURE([[stmt objectForColumn: 2]
|
||||
isEqual: [OFData dataWithItems: "abc"
|
||||
count: 3]]);
|
||||
break;
|
||||
case 1:
|
||||
OF_ENSURE([[stmt objectForColumn: 0]
|
||||
isEqual: [OFNumber numberWithInt: 7]]);
|
||||
OF_ENSURE([[stmt objectForColumn: 1]
|
||||
isEqual: @"Test"]);
|
||||
OF_ENSURE([[stmt objectForColumn: 2]
|
||||
isEqual: [OFData dataWithItems: "xyz"
|
||||
count: 3]]);
|
||||
break;
|
||||
default:
|
||||
OF_ENSURE(0);
|
||||
}
|
||||
}
|
||||
|
||||
[OFApplication terminate];
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue