Skip to content

Commit 1f65b08

Browse files
committed
Implementation for WCTSelectBase init
1 parent 1ede083 commit 1f65b08

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

apple/WCDB/interface/chaincall/WCTSelectBase.mm

+18
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,30 @@
2121
#import <WCDB/WCTChainCall+Private.h>
2222
#import <WCDB/WCTCore+Private.h>
2323
#import <WCDB/WCTExpr.h>
24+
#import <WCDB/WCTResult.h>
2425
#import <WCDB/WCTSelectBase+Private.h>
2526
#import <WCDB/WCTSelectBase.h>
2627
#import <WCDB/handle_statement.hpp>
2728

2829
@implementation WCTSelectBase
2930

31+
- (instancetype)initWithResultList:(const WCTResultList &)resultList fromTable:(NSString *)tableName
32+
{
33+
if (self = [super init]) {
34+
if (resultList.size() == 0) {
35+
WCDB::Error::ReportInterface(_core->getTag(),
36+
_core->getPath(),
37+
WCDB::Error::InterfaceOperation::Select,
38+
WCDB::Error::InterfaceCode::NilObject,
39+
[NSString stringWithFormat:@"Selecting nothing from %@ is invalid", tableName].UTF8String,
40+
&_error);
41+
return self;
42+
}
43+
_statement.select(resultList, resultList.isDistinct()).from(tableName.UTF8String);
44+
}
45+
return self;
46+
}
47+
3048
- (instancetype)initWithCore:(const std::shared_ptr<WCDB::CoreBase> &)core
3149
{
3250
if (self = [super initWithCore:core]) {

0 commit comments

Comments
 (0)